note 28813 added to language.types.string
| From: | Jeff at rack1 dot php dot net | Date: | Fri, 24 Jan 2003 17:28:27 +0000 |
| Subject: | note 28813 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-42699@lists.php.net to get a copy of this message | ||
This is why this is right:
$beer = 'Heineken';
echo "$beer's taste is great"; // works, "'" is an invalid character
for varnames
echo "He drank some $beers"; // won't work, 's' is a valid character for
varnames
echo "He drank some ${beer}s"; // works
In all these examples, the php code is looking for the variable $beer.
In the first one, it works because when it finds $beer's it actually finds $beer and stops at
the '.
In the second one, it doesn't work because there is no variable designated as $beers.
The third one works because the php code reads { and } as specifying what the actually variable is
that it should be looking for. The { and } allow you to add onto the variable.
--
http://www.php.net/manual/en/language.types.string.php
http://master.php.net/manage/user-notes.php?action=edit+28813
http://master.php.net/manage/user-notes.php?action=delete+28813
http://master.php.net/manage/user-notes.php?action=reject+28813