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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2021 The PHP Group
All rights reserved.
Last updated: Tue Jun 22 15:01:24 2021 UTC