note 17946 deleted from control-structures.for by spic

From: Date: Wed, 28 Aug 2002 08:34:57 +0000
Subject: note 17946 deleted from control-structures.for by spic
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-35868@lists.php.net to get a copy of this message
THere is no immediate need to force a typecast: function a($start_index) { for($i = $start_index; $i < 10; $i++) echo "\$i = $i\n"; } a('Eternity!'); will run to infinity, but: function a($start_index) { for($i = $start_index; $i < 10; $i+=1) echo "\$i = $i\n"; } will not, since the += operator makes PHP typecast $i to an int and discard of the STRING eternity and evaluate it as zero...

« previous php.notes (#35868) next »