Re: PHP_SELF syntax

From: Date: Tue, 25 Feb 2003 02:47:14 +0000
Subject: Re: PHP_SELF syntax
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-137028@lists.php.net to get a copy of this message
on 24/02/03 11:42 AM, Jason Lange (jslange@myrealbox.com) wrote: > What you might try is removing the single-quotes from around PHP_SELF. > > Before: $_SERVER['PHP_SELF'] > After: $_SERVER[PHP_SELF] > > Another note: as far as I can tell you do not need the braces ({}) to > enclose a variable within a double-quoted string. I may be wrong, but > nothing I've read advocates doing this, and I've never had a problem > with my code when I've written it this way. Wrapping vars in braces helps clarify the code, and can avoid problems like: <? $price = '44.99'; echo "Price: US$$priceeach"; // probably won't work echo "Price: US${$price}each"; // will work for sure echo "Price: US$" . $price . "each"; // will work, but not my pref ?> I've also found it helps with things like: <? echo "<a href='{$_SERVER['PHP_SELF']}'>click</a>"; ?> ... where normally the single quotes would cause confusion, or require the href to be wrapped in escaped double quotes. In otherwords, wrapping $vars in {braces} provides clarity to both the PHP parser, and to the writer, IMHO. Justin

« previous php.general (#137028) next »