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

middle

Maximum how many arguments are allowed in a function in PHP?

middle

What is the difference between MySQL, MySQLi and PDO?

junior

What are the differences between die() and exit() functions in PHP?

Bình luận

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

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