Gurbir Singh

Data Types

In any programming language, data type describes the kind of value that can be stored in a variable and also the type of operations that can be performed on it. PHP supports ten primitive data types which are described as under : Scalar Data Type These are the...

DATE AND TIME FUNCTIONS

Date and time functions in PHP help in retrieving date and time from the server and then format the result by various methods given in PHP.The output of these functions depends upon the locale settings of the server. Date and time functions are described below with...

PHP String Functions

A string is a combination of characters and string functions in a programming language are used to manipulate strings. For example: $string = “PHP string handling functions.”; Difference between single and double quoted strings in PHP: In single quoted strings,...

PHP Output Methods

Output methods are used to display the data or output on screen. Various methods are provided by PHP for the same. These methods and their usage is as described below: print methodecho methodprintf methodsprintf methodvar_dump methodprint_r method 1.  PRINT :...

PHP Magic Constants

In PHP, the constants who change themselves depending upon the way they are used are known as Magic Constants. There are nine such constants in PHP. Unlike other constants magical constants are resolved at compile time. These are case-insensitive constants. Magical...

PHP Constant Arrays

Array constant can also be created using define() function. Example : <?php define(“weekdays”, [“Sunday”, “Monday”, “Tuesday”,”Wednesday”, “Thursday”]); echo weekdays[0]; ?>

PHP Constants

A constant is an identifier whose value cannot be changed once it is declared in the program. Rules for declaring a constant :  Constants are case-sensitive and conventionally are always UPPERCASE.A valid constant name always starts with a letter or an...

Variable Scope

Scope can be defined as the visibility of a variable throughout the program where it can be used or referenced. Three PHP variable scopes are as listed below: LocalGlobalStatic 1.  Local Variables The variables whose scope or visibility is limited within the function...

PHP Variables

Variables are used to store data which are further used and manipulated as per requirement or instructions. In PHP,  a variable name is declared with a ‘$’ symbol and is followed by the variable name. It can be assigned a value using Assignment Operator (=)....

PHP Comments

Comments are used by programmers while programming irrespective of the programming language. They make the computer program more understandable to the reader and are not interpreted or compiled while execution. PHP contains multiple ways of commenting. Single-line...