Variable is name given to the storage area and its value change during programming execution is known as variable. The variable are use to store data. like number of arrays.
PHP variables begin with a dollar sign ($) as shown below.Syntax
$var_name = "Value";
|boolean||True or false|
|array||TList of items|
|object||Install of a class|
<?php $Greeting = 'Hello World!'; ?> <html> <head> <title><?php echo $Greeting; ?></title> </head> <body> <?php echo $Greeting; ?> </body> </html>O/P
A variable's scope determines the locations from which the variable can be accessed.PHP variables are either super global, global, or local.
Superglobal variables are predefined arrays, including $_POST and $_GET. They are accessible from anywhere on the page.The complete list of super global is shown below.
Global variables are visible throughout the script in which they are declared. However, they are not visible within functions in the script unless they are re-declared within the function as global variables
Variables in the function scope are called local variables. Local variables are local to the function in which they are declared.
Constants are like variables except that, once assigned a value, they cannot be changed. Constants are created using the define() function and by convention (but not by rule) are in all uppercase letters. Constants can be accessed from anywhere on the page.
A constant Is a identifier for a simple value. As the name suggest, that value cannot change during execution of the script.Syntax