note 15271 added to language.types.string
| From: | John dot Dalton at varrqnuht dot net | Date: | Tue, 04 Sep 2001 05:56:21 +0000 |
| Subject: | note 15271 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-17598@lists.php.net to get a copy of this message | ||
<p>I've noticed that variable expansion is done at the time of assignment. This means
that if you change the value of a variable referenced from within a string, the contents of the
string don't change to match the new value.
<p>For example:</p>
$dog = "beagle";
$breeds = array("labrador", "terrier", "rottweiler");
$favourite = "My favourite breed of dog is $dog.\n";
foreach ($breeds as $dog)
{
print $favourite;
}
<p>Produces:</p>
My favourite breed of dog is beagle. (3 times)
<p>If anyone knows a way to force the string to be reevaluated, I'd love to hear about
it. :)
http://www.php.net/manual/en/language.types.string.php