Câu hỏi phỏng vấn PHP
Câu hỏi

What does $GLOBALS mean?

Câu trả lời

What does $GLOBALS mean in PHP?

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:

  1. 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.

  2. 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'].

  3. Alternatively, you can use the global keyword inside the functi...

entry

entry

Gợi ý câu hỏi phỏng vấn

senior

Store an array as JSON or as a PHP serialized array?

junior

Is there a difference between isset and !empty ?

junior

Differentiate between echo and print()

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào