Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 9th, 2007, 07:50 AM
Authorized User
 
Join Date: Feb 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default help with 'break'

Hello Everybody,

I'am having problems using the break statement.I looked for help
and saw the following link informative>>>>>>>>
http://www.php.net/~derick/meeting-n...ml#adding-goto
>>>>>>>...but the problem is that whe i use the ' blah: ' ,statement
i get an error..is it to do with activating some extension???

iam using the follwing code:--

<?php
echo"<br><br> SEE if we can use break";
break blah;
echo"<br> This should not be shown";
blah:
echo"<br>If previous statement is not shown then break works";
?>

 
Old March 13th, 2007, 08:11 AM
Friend of Wrox
 
Join Date: Nov 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

What are you trying to do this code seems like it isn't suppose to do anything besides give errors. It makes no sense.
First of all what is blah it is not a variable since it doesn't have $ in front of it. And what is this break suppose to do. I've only seen the break command in a switch statement or loop.
here is an example when to use the break command:
Code:
   switch ($i) {
   case 5:
       echo "At 5<br />\n";
       break 1;  /* Exit only the switch. */
   case 10:
       echo "At 10; quitting<br />\n";
       break 2;  /* Exit the switch and the while. */
   default:
       break;
   }
What are you trying to achieve?

__________________________________________________ ________
I am DJ Kat...that's my name. Its a D and a J and a Kat with a K.
 
Old March 15th, 2007, 09:41 AM
Authorized User
 
Join Date: Feb 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

thanks for replying DJ Kat, you guessed it right 'blah' is NOT a variable it is a 'static' variable.....i know 'break', without a static label is only used in breaking out of nested 'if' loops or as u mentioned in the case of switch.....
What i was trying to do was to find an equivalent of GOTO statement used in C, in php5.......but too my pity the link that i have given above mentions minutes of a meeting of the group of php developers..so the break with a static label may be present in newer versions of php,,, but till now its not there in php5......

i however found a patch developed by someone to get a GOTO running in php....but i dont know how to use it>>>here's the link >>>>>> http://pecl.org/patches/opcode_goto_5.1.0.diff.....see if you can help me .......

 
Old March 15th, 2007, 09:04 PM
Friend of Wrox
 
Join Date: Nov 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I've seen goto in old basic and flash but I wonder, why would you need the GOTO statement? There different ways to approach your problem i think the GOTO statement has become obsolete in modern programming languages.

I am very confident that what ever you want to build you won't need the GOTO thing.


__________________________________________________ ________
I am DJ Kat...that's my name. Its a D and a J and a Kat with a K.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Why there isn't a "break"? XVenus Java Basics 1 September 4th, 2007 06:37 AM
Page Break Dhawood ASP.NET 2.0 Basics 0 August 8th, 2006 08:02 AM
break up line crmpicco Javascript How-To 1 June 6th, 2005 06:54 AM
how do i break it up? kuehhc Beginning PHP 3 January 19th, 2005 09:52 AM
Unable to Break at Break point Girishbk VB.NET 2002/2003 Basics 0 January 18th, 2005 08:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.