SESSION Data is stored on the server. This can be used to move data from one page to another across the website. Example When a user logs in to the website, we store user’s id in a session. This way ...
Category: PHP Tutorials
PHP Tutorials for Beginners – Here we will help you to learn how to create a dynamic and interactive website using PHP, HTML and CSS.
phpsupport | phpsupportdesk Latest Articles
PHP DB Connect
pHpSupportHow to create a connection with MySQL? Use mysqli_connect("host", "username", "password"); How to connect to database? Use mysqli_select_db("databasename", "connection"); How to insert data into MySQL database using PHP? We can run MySQL query using mysqli_query Use : mysqli_query("connection", "MySQL Query"); ...
Dbase MySQL
pHpSupportIn these tutorials, we will come to know how PHP can be connected to a database. In a database, there can be multiple tables. Each table can have multiple fields How to create a database We are considering ...
Arrays
pHpSupportArrays are used to store many values in single variables. Eg. Name of fruits In Php, array can be declared as the following Array($val1, $val2); Please check the following screenshot CODE <?php $fruitNames = array("Grapes","Banana","Papaya","Mango"); echo $fruitNames[0]; ?> OUTPUT IS ...
Operators
pHpSupportFor Addition use + Eg. $a + $b For Subtraction use – Eg. $a – $b For Multiplication use * Eg. $a * $b For Division use / Eg. $a / $b For getting remainder of division (modulus) Eg. $a ...
Loops
pHpSupportIn PHP the loops are of following types for foreach do while while For loop For(variable start point; till condition; increment or decrement) CODE <?php for ($days = 1; $days <= 7; $days++) { echo “Day number is : “.$days.” ...
Conditional Statements
pHpSupportIn php, following are the conditional statements If statement If else statement If elseif statement Switch statement if ($condition) { echo “”; } CODE – If statement <?php $str = “God is one”; if(isset($str)) { echo “This variable is set”; ...
String Functions
pHpSupportA String is simply a sequence of characters like ‘THIS IS PHP!’. PHP contains a huge variety of string functions. The PHP string functions basically is an important part of the PHP Core. PHP contains near about one hundred string ...
Data Types
pHpSupportPHP supports the following data types String Float(Double) Integer Boolean Array NULL Resource Object <?php Echo “This is nice”; // this is an example of string Echo 1; // this is an example of integer Echo -1; // this is ...
Variables
pHpSupportVariable Every variable starts with "$" eg. Assignment of a string to a variable. $var = "God is a power"; <?php $var = "God is a power"; echo $var; // To print a variable value ?> If you will see ...
Concat. & Comments
pHpSupportConcatenation Concatenation can be done by using "." in PHP CODE <?php $var = "ABCD"; echo $var." Here"; ?> OUTPUT PHP Comments In PHP, comments can be given by using the following If you want to give comment to single ...
Include & Require
pHpSupportHow to include other PHP file in your current file You can use the content from one PHP file to another. Include("filename.php"); Here filename.php is present on the same path as the file in which you are currently working. ...
Constants
pHpSupportConstants This returns the value of the constant. Constant in PHP can be declared by using keyword “define” Eg. define(“MAXLENGTH”, “100”); CODE <?php define(“MAXLENGTH”, “100”); echo MAXLENGTH; ?> OUTPUT We can define the constants in the config file of the ...
Time Functions
pHpSupportStrtotime It converts the date into unix time stamp format. <?php echo $dateTime=strtotime(“13-02-2016”); ?> OUTPUT To add no. of days in current date <?php $currDate = date(‘Y-m-d’) ; // 2016-04-02 $dateTime=strtotime(“$currDate + 5 days”); echo date(“Y-m-d”, $dateTime); ?> OUTPUT You ...
Date
pHpSupportTO DISPLAY THE CURRENT DATE <?php $current_date = date("Y-m-d"); echo $current_date; ?> OUTPUT If you want to show current date with Hours, Minutes and Seconds. Then try the following code. <?php $current_date = date("Y-m-d H:i:s"); echo $current_date; ?> OUTPUT If ...