note 73591 added to control-structures.do.while
| From: | sammyatthestags at osu1 dot php dot net | Date: | Fri, 02 Mar 2007 17:39:28 +0000 |
| Subject: | note 73591 added to control-structures.do.while | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124017@lists.php.net to get a copy of this message | ||
Not entirely sure what that script is meant to do, but pretty sure it should be
while(1) [not while(0)]
Here's a perhaps clearer example which repeatedly multiple a number by 0.2 until it becomes
less than 5.
<?php
$i = 1000000;
$factor = 0.2;
do {
echo "i = $i. ";
if ($i < 5) {
echo "i is not big enough";
break;
} else {
echo "i is ok<br>";
}
/* process i */
$i *= $factor;
} while (1);
?>
This outputs
i = 1000000. i is ok
i = 200000. i is ok
i = 40000. i is ok
i = 8000. i is ok
i = 1600. i is ok
i = 320. i is ok
i = 64. i is ok
i = 12.8. i is ok
i = 2.56. i is not big enough
----
Server IP: 69.147.83.197
Probable Submitter: 82.21.198.141
----
Manual Page -- http://www.php.net/manual/en/control-structures.do.while.php
Edit -- https://master.php.net/note/edit/73591
Del: integrated -- https://master.php.net/note/delete/73591/integrated
Del: useless -- https://master.php.net/note/delete/73591/useless
Del: bad code -- https://master.php.net/note/delete/73591/bad+code
Del: spam -- https://master.php.net/note/delete/73591/spam
Del: non-english -- https://master.php.net/note/delete/73591/non-english
Del: in docs -- https://master.php.net/note/delete/73591/in+docs
Del: other reasons-- https://master.php.net/note/delete/73591
Reject -- https://master.php.net/note/reject/73591
Search -- https://master.php.net/manage/user-notes.php