RE: [PHP] Re: Value of $_* variables
| From: | Ford, Mike [LSS] | Date: | Wed, 06 Mar 2002 12:53:22 +0000 |
| Subject: | RE: [PHP] Re: Value of $_* variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-87450@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: CC Zona [mailto:email@cczona.com]
> Sent: 06 March 2002 05:52
> To: php-general@lists.php.net
> Subject: Re: [PHP] Re: Value of $_* variables
>
>
> In article <php.general-87415@news.php.net>,
> php-general@gremlins.com.hk (Jason Wong) wrote:
>
> > echo "$doo[dah]"; # is correct
>
> If constant 'dah' is defined, and its value is the name of
> the key you wish
> to access from array '$doo'. But if the string literall
> 'dah' is itself
> the name of the key you are trying to access, then the above is *not*
> correct. For that, use:
That's incorrect. I thought that, too, until a kindly PHP guru explained that $-interpolation
inside double-quotes doesn't know about constants and ALWAYS interprets
"$doo[dah]"
the same as
$doo['dah']
(And even as a straight reference, if the constant dah is undefined $doo[dah] is interpreted as
$doo['dah'], with a -- usually suppressed -- warning being issued. But I do agree that
this is bad practice and should never be relied upon.)
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211