note 15271 deleted from language.types.string by jmcastagnetto

From: Date: Wed, 05 Sep 2001 19:15:37 +0000
Subject: note 15271 deleted from language.types.string by jmcastagnetto
Groups: php.notes 
Request: Send a blank email to php-notes+get-17662@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. :)

« previous php.notes (#17662) next »