|
How to define Variable Scope in Php?
If you define a variable within a function that means variable is only available within that function. This variable cannot CALL in another function or in the body of your program code. These types of variable are known as a variable's scope. The scope of a variable defined within a function is local to that function. If you want to use variable that is defined in the main body of program code. Remember It must reference using global keyword.
<?php
function_SubNumber ( )
{
global $sum = 4 - 4
}
$sum = 0
Subnumber ( )
echo "4 - 4 = ".$sum
?>
|