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:

  • New offer for you guys..................?                     Click here to visit new and fresh software and much more for you guys 100%… Read More
  • sikkinc-Home ||tempe bicycle|| ||arizona beach cruiser|| ||beach cruiser|| ||sikkinc|| ||hbbc|| ||micargi|| ||tempe beach cruiser|| ||Huntington Beach Bi… Read More
  • Sell Your Macbook Now Sell Your Macbook,Ipone,Ipade Normal 0 false false false EN-US X-NONE X-NONE … Read More
  • AZBEACHBIKES - Home ||BEACH CRUISER|| ||BEACH CRUISERS|| ||CUSTOM BEACH CRUISERS|| ||MICARGI|| ||SOUL CRUZERS||  || HBBC CRUISERS|| sikk inc has been pr… Read More
  • myitbuddies myitbuddies is a web programming tutorial blog. In tutorials we mainly focused on programming queries related to php, mysql, javascript, css, css3, j… Read More

1 comment: