PHP Local Variables - phptpoint

PHP Local Variables

/ins>

Local Variable

=> Local variables are always initialize inside the funtciob body.

=> Local variable cant work outside function body.

Output
Sum of given no = 300
Subtraction of given no = 300

Here define a variable $x and $y . Variable $x and $y has been defined inside add( ) function so these variables are not accessible outside the add( ) function.
Now if you want to access local variable $x and $y inside the sub( ) function then declare it first then use.