php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43787 [DE] Documentation bug at "do...while"-doc
Submitted: 2008-01-08 14:48 UTC Modified: 2009-02-09 17:19 UTC
From: f dot ach at web dot de Assigned: sammywg (profile)
Status: Closed Package: Translation problem
PHP Version: Irrelevant OS:
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: f dot ach at web dot de
New email:
PHP Version: OS:

 

 [2008-01-08 14:48 UTC] f dot ach at web dot de
Description:
------------
There is a mistake in the documentation for do...while:

Closing the do...while with 

}while(0);

as documented in "http://de2.php.net/manual/de/control-structures.do.while.php"

will cause only one run of the loop.

Correctly it should be:

}while(true);

Reproduce code:
---------------
$a = 0;
do{
  echo $a;
  $a = $a + 1;
  if ($a>5) break;
}while(0)

Expected result:
----------------
0
1
2
3
4
5

Actual result:
--------------
0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-08 16:19 UTC] bjori@php.net
To quote the doc: "Don't worry if you don't understand this right away or at all. You can code scripts and even powerful scripts without using this 'feature'."

The example is correct.
 [2008-01-08 16:30 UTC] bjori@php.net
..the German translation is however missing some explanations on the example.
 [2008-01-08 19:37 UTC] f dot ach at web dot de
I am sorry to answer you back, but a do...while loop simply runs only one time if closed by "while(0);"

In c this method works but in php "0" translates to "FALSE".

If you do not agree, simply check my example. (I did it 5 minutes ago)

Best
Friedo
 [2008-01-08 23:29 UTC] felipe@php.net
The construction do..while wasn't used for do make a loop. It's used on example to create a scope, where the rest the code of same scope will not be executed after perfomed a break statement.
 [2009-02-09 17:19 UTC] sammywg@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.


 [2020-02-07 09:57 UTC] phpdocbot@php.net
Automatic comment on behalf of sammywg
Revision: http://git.php.net/?p=doc/de.git;a=commit;h=e486d22b6564c12fba5fecf3a54606068856506c
Log: initial translation, fix bug #43787
 [2020-12-30 11:15 UTC] nikic@php.net
Automatic comment on behalf of sammywg
Revision: http://git.php.net/?p=doc/de.git;a=commit;h=ad9b1bd5fd421dd93a41968df7dbb5eaef3d3445
Log: initial translation, fix bug #43787
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 19:01:31 2024 UTC