PHP MySQL Database Tutorial

MySQL is the most popular database system that is used within PHP. Let’s first understand about MySQL. What is MySQL? MySQL is open-source Relational Database Management System (RDMS). The name of MySQL is a combination of “My” which is the name of co-founder Michael Widenius’s (main author of the original version of open-source MySQL)  daughter, and “SQL” is abstract from Structured Query Language. MySQL used by many popular websites …

Read morePHP MySQL Database Tutorial

Multiple-Inheritance in PHP

Multiple-Inheritance in PHP Multiple-Inheritance is the resources of the Object Oriented Programming Languages in which child class or subclass can inherit the resources of the multiple parent classes or superclasses. PHP does not support Multiple Inheritance but using interfaces in PHP, we can implement it. Using class with Traits: The trait is a type of class that enables multiple inheritance. Classes, objects, and traits that do not extend more …

Read moreMultiple-Inheritance in PHP

PHP For loop with Example

For loop in PHP : The for loop is the most potent loop, it combines the abilities to set up variables as we enter the loop, test for conditions while iterating loops, and it modifies variables after each iteration. Example:


In the above example, we are outputting the 10 times table from a for loop. Each for statement takes three parameters: An initialization expression. A condition …

Read morePHP For loop with Example

PHP isset() function

PHP isset is used to check whether the variable is set or not.The PHP isset() function returns false if variable contains a NULL value. Syntax:

Presentation of PHP isset: In the above diagram, the isset variable is null so it will return false. In the above diagram, the isset variable is 10, and it will return true. It means if the variable is set and not null, then …

Read morePHP isset() function

PHP Implode Function

PHP Implode( ) with Example PHP implode( )is used to join elements of an array with string.PHP implode( ) returns a string from an element of an array. It takes an array of a string and joins them together into one string. It re-joins any array elements and returns the resulting string, which may be put into a variable. Syntax:

Usage: The PHP implode( ) accept its parameter. …

Read morePHP Implode Function

PHP foreach Loop

PHP foreach Loop with Example PHP foreach loop is used to loop through the associative arrays. Syntax:

$array = associative array. $key = array key. &value = array keys value. $key and $value variables can be named anything. The $key will be equal to the arrays key, and $value will be equal to that key`s value. The loop ends when the last array key (=>) value pair reached. …

Read morePHP foreach Loop

How to use Date and Time in PHP

HOW TO USE DATE AND TIME IN PHP: PHP time and date function  informs us about current date and time. it can be manipulated also. How time() function works: The time() function would work by our server time and can be changed. It returns integer but not the argument. Date and time are stored in computer in UNIX Timestamp format. That calculates time in number of seconds on GMT …

Read moreHow to use Date and Time in PHP

PHP Tutorial

PHP Introduction PHP is a server-side scripting language which is used for web development. It stands for Hypertext Preprocessor. It is faster than another programming language. It supports multiple databases like MySQL, SQL, PostgreSQL and many more. History PHP was developed by Rasmus Lerdorf in 1995. It is used to develop a dynamic web application. The earlier name of PHP was a personal homepage. The PHP code is usually processed …

Read morePHP Tutorial

PHP Environment Setup

To install PHP, We have to installed AMP(Apache, MySQL and PHP) software. There are various AMP software available in the market. XAMPP (Cross-Platform, Apache, MySQL, PHP and Perl) for windows. WAMP (Windows, Apache, MySQL and PHP) for windows. LAMP (Linux, Apache, MySQL and PHP) for Linux. MAMP for Mac. SAMP for Solaris. FAMP for FreeBSD. Note: In this tutorial, we are using XAMPP software.  Follow these steps to run …

Read morePHP Environment Setup

PHP Example

We can create a simple program by writing the source code inside the php tag and save it with .php extension. Syntax:

Let us take an example of PHP.

← Prev Next →

PHP Variables

PHP Variable is the name of memory location used to hold the data.  In PHP, variable starts with $ symbol. Rules for PHP Variables. Variable starts with $ sign. Variable name must start with a letter or the underscore character. Variable name can contain alpha-numeric character (A-Z. 0-9). Variable name are case-sensitive ($name and $NAME are two different variables). Example

Output PHP Father: RasmusLerdorf In PHP, there are …

Read morePHP Variables

PHP $ and $$ Variables

PHP $var variable is a normal variable that stores any value. PHP $$var variable is a reference variable that stores the value of$var inside it. Let us take an example. Example 1

Output Hello 100 100 Example 2

Output : Rasmus Rasmus Rasmus ← Prev Next →

PHP Super Global Variables

There are various predefine “superglobals” in PHP. These variables can easily accessible in function or class. Following are the superglobals variables: $GLOBALS $_SERVER $_REQUEST $_POST $_GETetc. PHP $GLOBALS The “$GLOBAL” isa keyword that is used to accesssuper global variablefrom anywhere in the PHP script. Example 1:

Output 50 PHP $_SERVER PHP  $_SERVER is a PHP super global variable that holds the information about headers, paths, and script locations. …

Read morePHP Super Global Variables

PHP Echo And Print

In PHP, echo and print is used to get output data to the screen but there is some difference, between echo and print. PHP echo PHP echo is used to display the output data.It can be used with parentheses or without parentheses. We can pass multiple stringsseparated by(,) comma operator. It does not return any value. Example 1

Output RasmusLerdorfRasmusLerdorf Example 2 (pass multiple argument)

Output RasmusLerdorf …

Read morePHP Echo And Print

PHP Constant

PHP constant is an identifier(name) for a simple value. The value does not change during the script. It starts with a letter or underscore not $ sign. The define()function is used to create a constant. Syntax:


Output Welcome to PHP Tutorial Constants are Global PHP constant is automatically global. It can be used for entire script.Let’s take an example. Example

← Prev Next →

PHP Magic Constants

There are various predefine PHP Magic Constants. It starts with underscore(__) and ends with double underscore.  Magic Constant Description __LINE__ To check current line number of the file. __FILE__ To check full path and filename of the file. __FUNCTION__ To check function name. __CLASS__ To check class name. __METHOD__ To check class method name. PHP_VERSION To check PHP version. PHP_INT_MAX To check PHP integer value limit. etc Let us …

Read morePHP Magic Constants

PHP Data Types

PHP data type is used to hold the various types of data or value.  There are three types of data types in PHP. It is a loosely data typed language, so there is no need to declare data type like int,float etc. InPHP,there are some function to check data type and its value. gettype(): It is used to check only data type. var_dump(): It is used to check the …

Read morePHP Data Types

PHP Operator

PHP Operator is used to perform operations on variable and values. Following are the types of Operator: PHP Arithmetic Operator PHP Arithmetic operator is used for arithmetical operations, such as addition, subtraction, multiplication etc. Operator Description Example  + Addition $x + $y  – Subtraction $x – $y  * Multiplication $x * $y / Division $x / $y  % Modulus $x %$y ** Exponentiation $x ** $y PHP Assignment Operators …

Read morePHP Operator

PHP Comment

PHP commentis a line of code that is not executed. It is often used by developer to understand the code. PHP support single and multiple comments. In other language like C, C++ and Unix comments, syntax is same in PHP. Single Line Comment Multiple Comment Single Line Comment: We can comment single line by // slash. Example

Output Single Line comment by double-slash Multi Line Comment: We can …

Read morePHP Comment

PHP if..Else..Elseif

PHP conditional statements are used to test the conditions. It supports different types of conditional statement. Following are the types of conditional statement if statement ..else statement ..elseif….else statement switch statement PHP if Statement PHP if statement is used to execute the code block if the one condition is true. Syntax:


Output Nos is Equall to 5 PHP if… else Statement PHP if- else statement is …

Read morePHP if..Else..Elseif