ID: 33676
User updated by: richard dot quadling at bandvulc dot co dot uk
Reported By: richard dot quadling at bandvulc dot co dot uk
Status: Bogus
Bug Type: Documentation problem
Operating System: All
PHP Version: Irrelevant
New Comment:
Ah I see. It was the 1 syntax bit that threw me. I didn't realise it
was in comparison to if.
Previous Comments:
------------------------------------------------------------------------
[2005-07-13 16:03:05] [EMAIL PROTECTED]
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 10:32:23] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33676&edit=1