473,320 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Why no error?

Why no error on this code?

<?php
for ($i=0;$i<5;++$i)
{
if ($i==2)
continue
print "$i\n";
}
?>

Output is "2".
May be true must be "continue;"?
Sep 23 '08 #1
2 1178
That's weird and interesting. You're right, you need the semicolon.

On Sep 23, 1:20*pm, "Andrew G. Koptyaev" <kopty...@gmail.comwrote:
Why no error on this code?

<?php
for ($i=0;$i<5;++$i)
{
*if ($i==2)
* continue
*print "$i\n";}

?>

Output is "2".
May be true must be "continue;"?
Sep 23 '08 #2
..oO(703designs)
>That's weird and interesting.
It's documented behaviour. The example was taken from the manual and
describes a situation which you should avoid.

Maybe it becomes clearer with a little rearrangement, it's still the
same code:

<?php
for ($i = 0; $i < 5; ++$i) {
if ($i == 2) {
continue print "$i\n";
}
}
?>

Since print is a special language construct and always returns 1, the
above is equivalent to

<?php
for ($i = 0; $i < 5; ++$i) {
if ($i == 2) {
print "$i\n";
continue 1;
}
}
?>

http://www.php.net/manual/en/control...s.continue.php
>You're right, you need the semicolon.
Yep.

Micha
Sep 23 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
25
by: James L Bryant | last post by:
At bootup this morning before displaying the Windows logo the following error string is displayed: Database corrupt.PsMain: 568c PsMain: 98bd PsMain: 9b45 PsMain: 49d6b PsMain: 3ca6f PsMain:...
4
ThatThatGuy
by: ThatThatGuy | last post by:
Im getting this unsual error .... when getting to desgin mode... ...... can anyone help me on this
0
by: jadeite100 | last post by:
Hi All: I am new to displaytag and Maven. I download the displaytag-examples from the url "http://sourceforge.net/projects/displaytag/files/" it is part of the "displaytag-1.2-src.zip" I am using...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.