continue break removed from php

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

continue break removed from php

Post by yacahuma »

Hello, I just check and they remove break continue from php in the latest version. Can someone please tell me what whas wrong with that and what are we supposed to use now for the same thing?

Thank you
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: continue break removed from php

Post by Weirdan »

What's your source?
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: continue break removed from php

Post by yacahuma »

User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: continue break removed from php

Post by greyhoundcode »

tinsology.net wrote:

Code: Select all

for($i = 0; $i < 3; $i++)
{
    for($j = 0; $j < 3; $j++)
    {
        if($i == 1)
            break 2;
        echo "$i:$j\n";
    }
}
The above will output:

0:0
0:1
0:2
Do you know I wasn't even aware you could do that with break.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: continue break removed from php

Post by AbraCadaver »

break/continue $var - so this is what I believe they removed:

Code: Select all

$var = 2;

for($i = 0; $i < 3; $i++)
{
    for($j = 0; $j < 3; $j++)
    {
        if($i == 1)
            break $var;
        echo "$i:$j\n";
    }
}
And also:

Code: Select all

continue $var;
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: continue break removed from php

Post by yacahuma »

Ok, I thought they removed the whole continue break. I personally dont use break $var. So at least for me is ok, IF that is what it is
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: continue break removed from php

Post by AbraCadaver »

yacahuma wrote:Ok, I thought they removed the whole continue break. I personally dont use break $var. So at least for me is ok, IF that is what it is
I don't use it either and have never seen it in any code. Thank God. That would be horrible to maintain/debug.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: continue break removed from php

Post by VladSun »

AbraCadaver wrote:I don't use it either and have never seen it in any code. Thank God. That would be horrible to maintain/debug.
break/coontinue are not so bad, IMHO - they are both "near jumps" just like IF-ELSE and they behave like a "local-scope-void-return" statement. Can't say the same for goto(), though :)

PS: I missed the "$var" note in the discussion. And yes - I agree break/continue $var is not good :)
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
greyhoundcode
Forum Regular
Posts: 613
Joined: Mon Feb 11, 2008 4:22 am

Re: continue break removed from php

Post by greyhoundcode »

VladSun wrote:Can't say the same for goto(), though :)
Nice cartoon on the PHP Manual's Goto() page!
Post Reply