RE: [PHP] What am I not understanding about $GLOBALS['myvar'] vs global $myvar?
| From: | Jennifer Goodie | Date: | Wed, 26 Mar 2003 22:10:02 +0000 |
| Subject: | RE: [PHP] What am I not understanding about $GLOBALS['myvar'] vs global $myvar? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-141128@lists.php.net to get a copy of this message | ||
>Actually I didn't. ;-)
>$GLOBALS[$key] is incorrect and depricated AFAIK.
>$GLOBALS['$key'] (with the single quotes) is the proper way to write these
Wouldn't it need to be $GLOBALS["$key"] because single quotes tell the
parser not to expand variables? I think you are misinterpreting the part of
the manual that says "You should always use quotes around an associative
array index." Even though a variable may contain a string it is not a
string and therefore does not need quoting because there is not danger of it
being interpreted as a constant. Look at the manual page on arrays, it
shows arrays with variable indices without quotes.
http://www.php.net/manual/en/language.types.array.php