Lecture #4
Hi!
guys today i want to talk about the the PHP variable scope
so here we go.........................................................................................
There are four scope of php variables
so i discuss one by one below as:Hi!
guys today i want to talk about the the PHP variable scope
so here we go.........................................................................................
There are four scope of php variables
- Local
- global
- static
- parameter
1.Local scope
If any variable declare in the function of php then we say that it's life is affilicate with the php function and it's scope is local .not accessible from the out side the php function
like as
<?php
$n=10;//global scope
function myfun()
{$h=7;//local scope of the variable
}
myfun();
?>
Static scope of variable
<?php
function myfun()
{
static $n=0;//static scope of variable and static declaration
echo $n;
$n++;
}
myfun();
myfun();
myfun();
?>
parameter scope
<?php
function myfun($x)
{
echo $x;
}
myfun(5);
?>
for learning subscribe my blog feed..
thanks for comments
ReplyDelete