Thursday 18 February 2016

PHP Variable Scope

Local Variable

     A local variable is accessible only the block where it has defined. When a code block over then the entire local variable inside of block automatically released by the compiler.
<?php
           
            function fun1()
            {                      
                        $a=10;
                        echo $a;
            }
            function fun2()
            {
                        echo $a+10;
                        // Error : Undefined variable: a because it has not defined in fun2 and a is local variable for  fun1
            }          
?>
<?php
            //fun1();
            fun2();
?>

Global Variable

     The scope of a PHP variable depends on where it has defined I.e. when a variable is declared in top side of the PHP code block, then it becomes global variable for all PHP code block but not inside of a function.

Saturday 13 February 2016

M4.1-R4 Application of .NET Technology

M3-R4 Programming and Problem Solving through ‘C’ language

Internet Technology and Web Design