> -----Original Message----- > From: Erik Price [mailto:[EMAIL PROTECTED]] > Sent: 24 June 2002 18:12 > > On Monday, June 24, 2002, at 12:15 PM, Johnson, Kirk wrote: > > > When you echo out an array element, the name needs to be enclosed in > > curlies, e.g., > > > > echo {$_SERVER['PHP_SELF']} > > I think that this is only important when using an associative array > element reference within certain kinds of quotes. Like this: > > // this won't work b/c of quoting issues > echo "This script is called $_SERVER["PHP_SELF"]"; > > // this should work fine IIRC > echo "This script is called $_SERVER['PHP_SELF']";
Nope. Quoted array indexes don't work inside strings. > // this should also work if for some reason you needed > // to use double quotes within the array element reference > // (to interpolate a variable, for instance) > echo "This script is called {$_SERVER["PHP_SELF"]}"; Nope. The {} don't change the quoting issues you mentioned in your first (non-working) example. > // and this is the same thing really > echo "This script is called ${_SERVER["PHP_SELF"]}"; ... and fails for the same reason! You can use: echo "This script is called {$_SERVER['PHP_SELF']}"; echo "This script is called ${_SERVER['PHP_SELF']}"; echo "This script is called $_SERVER[PHP_SELF]"; or even echo "This script is called " . $_SERVER['PHP_SELF']; 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: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php