note 17946 added to control-structures.for

From: Date: Fri, 04 Jan 2002 14:26:57 +0000
Subject: note 17946 added to control-structures.for
Groups: php.notes 
Request: Send a blank email to php-notes+get-24393@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... -- http://www.php.net/manual/en/control-structures.for.php http://master.php.net/manage/user-notes.php?action=edit+17946 http://master.php.net/manage/user-notes.php?action=delete+17946 http://master.php.net/manage/user-notes.php?action=reject+17946

« previous php.notes (#24393) next »