Re: $i++ + string??
| From: | Richard Lynch | Date: | Sun, 07 Oct 2001 03:23:12 +0000 |
| Subject: | Re: $i++ + string?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70273@lists.php.net to get a copy of this message | ||
> Can any one explain to me why this is not working??
> $i = 1;
> while ($i <= 10) {
> echo "$i++ <br>";
> }
> i is staying set to 1 (and it never ends :c)
>
> but this works:
> $i = 1;
> while ($i <= 10) {
> print("$i <br>");
> $i++;
>
> }
Embedding $i inside a string is a convenience, but you can't do
mathematicaly operations inside a string...
How, for example, is PHP supposed to know you actually want $i++ to be an
increment instead of just ASCII "artwork" or output like you might do:
echo "$i+++++++++++++++++++++++$i<BR>\n";
You can do this, though:
echo $i++, "<BR>";
--
WARNING richard@zend.com address is an endangered species -- Use
ceo@l-i-e.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm