#31. PHP Local & Global Variable

  Local Variable

Run Code:

<?php
   

function test(){
      $a = 10;
     echo "Inside Function : $a <br>";

}
    test();
    echo "Out side Function : $a" ;
    ?>

-------------------------------------------------------------------------------

Global Variable:



Run Code:

<?php
     $a = 10;

function test(){
     global $a;
     echo "Inside Function : $a <br>";

}
    test();
    echo "Out side Function : $a" ;
    ?>

Comments

Popular posts from this blog

#30. PHP Recursive Function