The scope of a variable is the context within which it is defined. For the most part all PHP variables only have a single scope.
Notice: Undefined variable: a in D:\xampp\htdocs\var\index1.php on line 6
This script will not produce any output because the echo statement refers to a local version of the $a variable, and it has not been assigned a value within this scope
A second way to access variables from the global scope is to use the special PHP-defined $GLOBALS array.
The $GLOBALS array is an associative array with the name of the global variable being the key and the contents of that variable being the value of the array element. Notice how $GLOBALS exists in any scope, this is because $GLOBALS is a superglobal.
Another important feature of variable scoping is the static variable. A static variable exists only in a local function scope, but it does not lose its value when program execution leaves this scope
Static variables also provide one way to deal with recursive functions. A recursive function is one which calls itself. Care must be taken when writing a recursive function because it is possible to make it recurse indefinitely. You must make sure you have an adequate way of terminating the recursion.
what is difference between $(single doller) and $$(double doller).
The $k is the normal variable that stores any value.
The $$k is a reference variable that stores the value which can be accessed by using $ symbol before $k value.
Output :-
Trending Tutorials