php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #38547 manual bug
Submitted: 2006-08-22 15:18 UTC Modified: 2006-08-22 15:32 UTC
From: pb at tdcspace dot dk Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: xxx
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: pb at tdcspace dot dk
New email:
PHP Version: OS:

 

 [2006-08-22 15:18 UTC] pb at tdcspace dot dk
Description:
------------
manual bug (up to latest rel. at 12 aug 2006) :

Chapter 16. Control Structures 

do-while
--------

a do-while example loop is shown (the man. ex. below) which
should be endless by using "while (0);" where (0) indicates a false condition. note: the endless condition is used to illustrate the "break" statement to exit the loop instead.

the loop will terminate at once with while(0) - the correct syntax is while (1) or while(true) to make a endless loop.



Reproduce code:
---------------
<?php
do {
    if ($i < 5) {
        echo "i is not big enough";
        break;
    }
    $i *= $factor;
    if ($i < $minimum_limit) {
        break;
    }
   echo "i is ok";

    /* process i */

} while (0);
?>  



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-22 15:32 UTC] ohill@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

It is not a loop, but a control block. It should end after one pass (thus while false). Please read the paragraph before the example again.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC