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

entry

What is the purpose of php.ini file?

junior

What is the difference between single-quoted and double-quoted strings in PHP?

middle

Are Parent constructors called implicitly inside a class constructor?

Bình luận

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

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