on 24/02/03 11:42 AM, Jason Lange ([EMAIL PROTECTED]) 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


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to