make money free online
star business online
11:27 PM

variable

Posted by Business

this time online business , expain about variable . Scope can be defined as the range of availability a variable has to the program in
which it is declared. PHP variables can be one of four scope types:

· Local variables
· Function parameters
· Global variables
· Static variables

Local Variables

A variable declared in a function is considered local; that is, it can be referenced
solely in that function.Consider this listing:

$x = 4;
function assignx () {
$x = 0;
print "\$x inside function is $x.
";
}

assignx();

print "\$x outside of function is $x.
";

Execution of the above listing results in:

$x inside function is 0.
$x outside of function is 4.

As you can see, two different values for $x are output. This is because the $x located
inside the assignx function is local in nature. Modification of its value has no bearing
on any values located outside of the function. On the same note, modification of the
$x located outside of the function has no bearing on any variables contained in
assignx().

0 comments:

Post a Comment