Tuesday, 26 February 2013

PHP:Variables scope

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
  1. Local
  2. global
  3. static
  4. parameter
so i discuss one by one below as:

     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..




Related Posts:

  • PHP:Variables scope Lecture #4 Hi! guys today i want to talk about the the PHP variable scope so here we go............................................................… Read More
  • Chat point ! Visit here and meets millions of people share their feelings with them directly also share problem with him and find solutions thanks Don't miss t… Read More
  • Lecture #5 PHP Hi!guys Today i want to talk about the php string variables and much more.................. so here we go.................................  look… Read More
  • PHP:Variables Lectures#3 Hi!guys today i want to talk about the Variables of the PHP...................................... so here we go.........................… Read More
  • Superbird is the alternative to Google Chrom Best and Free download Superbird Browser for myITbird  click below and download now Superbird is the alternative to Google Chrome Super… Read More

1 comment: