Scope of a variable in PHP
Variable scope can be of tree types: variable can be local, global or super global.
When a variable is defined in PHP then its scope is local, meaning that it is accessible within a section of a code it is in, this variable is not accessible from a different function.
Global variables are accessible everywhere.
There are also super global variables, these are predefined. Example of super global variables are $_SESSION, $_POST, $_GET, $_ENV. I just list a few of them, for full list of super global PHP variables consult documentation.
YouTube video
Comments
Post a Comment