Re: _SERVER variable insd prnt sttmnt
| From: | 1LT John W. Holmes | Date: | Mon, 29 Apr 2002 15:30:09 +0000 |
| Subject: | Re: _SERVER variable insd prnt sttmnt | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-95173@lists.php.net to get a copy of this message | ||
> > //print "<LI><A
> > HREF='$_SERVER['PHP_SELF']?letter=$chars[$cnt]'>" .
This is the problem with not breaking out of a string to display a variable.
Ideally, you would do it this way:
print "<LI><A HREF='" . $_SERVER['PHP_SELF'] .
"?letter=" . $chars[$cnt] .
"'>";
But some people just have a problem with doing it that way, so you can use
braces.
print "<LI><A
HREF='{$_SERVER['PHP_SELF']}?letter={$chars[$cnt]}'>";
If you don't use the braces, how is PHP supposed to know what you mean. Do
you mean to print a variable called $_SERVER, followed by a literal
['PHP_SELF'], or do you mean an array? How is PHP supposed to decide for
you? Like your second variable, $chars. Is that an array? Do you mean to
print out the value of an $chars element, or do you mean to print out value
of $char, followed by "[", value of $cnt, followed by "]" ??
Hope that helps.
---John Holmes...