php global variables - Phptpoint

PHP Global Variables

PHP Summer Training/Internship with 2 Live Projects in Noida Fee is only 5500/-Click here to Book Your Seat.


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