What does $GLOBALS mean?
What does $GLOBALS mean?
In PHP, $GLOBALS
is a superglobal variable that is used to access global variables from anywhere in the PHP script, including from within functions or methods. It is an associative array that contains references to all variables that are currently defined in the global scope of the script.
Here's how $GLOBALS
works:
When a variable is defined in the global scope (outside of any function or class), it is automatically added to the $GLOBALS
array with the variable name as the key and the variable value as the value.
To access a global variable from within a function or method, you can use the $GLOBALS
array and specify the variable name as the key, like this: $GLOBALS['variableName']
.
Alternatively, you can use the global
keyword inside the functi...
entry
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào