note 16150 deleted from control-structures.for by spic
| From: | spic@php.net | Date: | Wed, 28 Aug 2002 08:34:55 +0000 |
| Subject: | note 16150 deleted from control-structures.for by spic | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-35867@lists.php.net to get a copy of this message | ||
You should always cast the looping index to an int if you're initializing it with another
variable. Otherwise you risk getting caught in an infinite loop. The following will run till Kingdom
comes:
function a($start_index) {
for($i = $start_index; $i < 10; $i++) echo "\$i = $i\n";
}
a('Eternity!');
More subtle is a(false), which also loops forever.