ID: 36523 User updated by: rjnewton at efn dot org Reported By: rjnewton at efn dot org Status: Open Bug Type: Documentation problem Operating System: Windows XP PHP Version: Irrelevant New Comment:
Documentation reference should have been Language Reference|Control Structures|do-while rather than Language Reference|Control Structures|while. Also, "thus $ < 5 will evaluate true." Should have been "thus $i < 5 will evaluate true." in the Expected Results section. Sorry, Joseph Previous Comments: ------------------------------------------------------------------------ [2006-02-25 02:48:44] rjnewton at efn dot org Description: ------------ Current PHP manual [Tue Nov 22 00:57:49 2005] suggests under Language Reference|Control Structures|while that while(0) keeps a loop in play until a break condition occurs. This is the reverse of the actual case. Reproduce code: --------------- <?php $i = 12; $factor = 0.5; $minimum_limit = 2; do { if ($i < 5) { echo "i is not big enough\n"; break; } $i *= $factor; if ($i < $minimum_limit) { break; } echo "i is ok\n"; /* process i */ } while (0); ?> Expected result: ---------------- Should make two full passes through the loop, the exit at the first if statement of the third loop, since $i will then be 3, thus $ < 5 will evaluate true. This is the behavior when while(1) is used as the control condition. Actual result: -------------- using while(0): D:\newtonj\PHPstuff>php hello.php i is ok using while(1): D:\newtonj\PHPstuff>php hello.php i is ok i is ok i is not big enough ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36523&edit=1