All in one (PHP code backend)only for admin
$lt;
";
//Variable can be used as string or integer
$message = 1;
$message = "PHP is the best!
";
// if we use $message = 1; // 1 will print
echo $message . "
";
echo "
";
//Print variable with double quotes
echo "name variable = $name" . "
";
// single quotes
echo 'name variable = $name' . "
";
echo "
";
//Variable Typing convert between string to integer or any data types.
$length = "10";
$breath = 20;
$area = $length * $breath; //Variable Typing Example
echo "Area: $area" . "
";
echo "
";
//Variables are case sensitive
$Name = " Walter White";
echo "$name is not equal to $Name " . "
";
echo "
";
//Variable Scope
$counter = 1;
function show_counter() {
// 2 will print
$counter = 2;
echo $counter . " two is printed
";
}
show_counter();
echo $counter . " one is ptinted now
";
echo "
";
//Global Variables
global $count;
$count = 3;
function show_global_counter() {
$count = 2;
echo $count . " function variable value
";
}
show_global_counter();
echo "
";
echo $count . " after function value
";
echo "
";
//Static Variable
function counter_static()
{
static $count = 5;
echo $count . "
";
$count = $count + 1;
}
counter_static();
echo "
";
//Predefined Variables
function print_global_variable() {
echo $GLOBALS['name']; // withour dollar sign
}
print_global_variable(); // Gloably access
echo "
";
//Variable of Variables
$countofcount = "count"; // count variable value will print by this
echo $$countofcount;
echo "
";
//isset()
echo isset ($$countofcount) ? "Variable is set": "Variable is not set";
>
Comments
Post a Comment