php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #33676 [chm] bug on control-structures.do.while.html
Submitted: 2005-07-13 10:32 UTC Modified: 2005-07-13 16:19 UTC
From: richard dot quadling at bandvulc dot co dot uk Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
 [2005-07-13 10:32 UTC] richard dot quadling at bandvulc dot co dot uk
Description:
------------
The do-while control structure mentions the use of break in a do-while loop, but does not say if it is supported in PHP or not.

The manual reads ...

"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'."

When it says I can code without this "feature" does this mean I do not need to use this "feature", because I don't understand the "feature", or I cannot use this "feature", because this "feature" is not supported?

I think the issue is that at the top of the page for do-while there is a statement ...

"There is just one syntax for do-while loops:"


Initially, I thought that the documentation meant that this "feature" was not available in PHP.

It is available in PHP5.0.4 (as seen by the code below - cli code).

Reproduce code:
---------------
<?php
echo "About to enter a while loop with a break.\n";
$iCount = 0;
$iBreakOn = 10;
while(True)
	{
	++$iCount;
	echo "Counted to $iCount\n";
	if ($iCount === $iBreakOn)
		{
		break;
		}
	}
echo "While loop exited with $iCount.\n";

echo "About to enter a do-while loop with a break.\n";
$iCount = 0;
$iBreakOn = 10;
do
	{
	++$iCount;
	echo "Counted to $iCount.\n";
	if ($iCount === $iBreakOn)
		{
		break;
		}
	}
while(True);
echo "While loop exited with $iCount.\n";
?>

Actual result:
--------------
About to enter a while loop with a break
Counted to 1
Counted to 2
Counted to 3
Counted to 4
Counted to 5
Counted to 6
Counted to 7
Counted to 8
Counted to 9
Counted to 10
While loop exited with 10
About to enter a do-while loop with a break
Counted to 1
Counted to 2
Counted to 3
Counted to 4
Counted to 5
Counted to 6
Counted to 7
Counted to 8
Counted to 9
Counted to 10
While loop exited with 10

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-13 16:03 UTC] nlopess@php.net
I think the documentation is pretty clear.
The example is in *PHP* and it demonstrates the use of a do{} while with breaks.

It says that there's just one syntax for do-while, which is correct. For example, 'if' has a lot more (if-endif).
 [2005-07-13 16:19 UTC] richard dot quadling at bandvulc dot co dot uk
Ah I see. It was the 1 syntax bit that threw me. I didn't realise it was in comparison to if.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 04:01:29 2024 UTC