Is there any differents between $GLOBALS[“test”] and global $test?
可以让我知道两者之间的基本区别吗
1 | $GLOBALS["test"] and global $test |
并且,如果我使用
and, will it make sense that, if i use
$GLOBALS["test"] instead of
$_SESSION['test']?
不,会话与全局可用变量不同。
$全球
An associative array containing
references to all variables which are
currently defined in the global scope
of the script. The variable names are
the keys of the array.
http://php.net/manual/en/reserved.variables.globals.php
说明:
Note: This is a 'superglobal', or
automatic global, variable. This
simply means that it is available in
all scopes throughout a script. There
is no need to do global $variable; to
access it within functions or methods.
他们为什么邪恶?