php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #29077 do...while(0)
Submitted: 2004-07-09 17:51 UTC Modified: 2004-07-09 18:03 UTC
From: oliver at burtchen dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: oliver at burtchen dot com
New email:
PHP Version: OS:

 

 [2004-07-09 17:51 UTC] oliver at burtchen dot com
Description:
------------
The while-condition for the example should be 1 and not 0.


Expected result:
----------------
Advanced C users may be familiar with a different usage of the do..while loop, to allow stopping execution in the middle of code blocks, by encapsulating them with do..while (1), and using the break  statement. The following code fragment demonstrates this:

<?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 (1);
?> 


Actual result:
--------------
Advanced C users may be familiar with a different usage of the do..while loop, to allow stopping execution in the middle of code blocks, by encapsulating them with do..while (0), and using the break  statement. The following code fragment demonstrates this:

<?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
 [2004-07-09 18:02 UTC] dave@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2004-07-09 18:03 UTC] oliver at burtchen dot com
Sorry, my report was not correct.
 [2020-02-07 06:12 UTC] phpdocbot@php.net
Automatic comment on behalf of dave
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=59d27e72d5458d7626c19c0a4d42b03180b0a1b8
Log: - Fix #29077.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 18 17:00:03 2025 UTC