php global variables - Phptpoint

PHP Global Variables

PHP 6 Months 100% Job Assistance Program. for more info... call on 8588829328

Global Variable

=> Global variables are always initialize outside the function body.

=> Global variable work inside the function body as well as outside function body.

=> To access Global variable we have to use global keyword.

Sum of given no = 300
Subtraction of given no = -100

In the above example
There are two variables declare $x and $y outside the function body.
Now if we want to call these global variable $x and $y inside add( ) and sub( ) function
then used “global” keyword before the variable name like “global $x” and “global $y”.

Latest Trending Technologies