Re: GOTO and/or BREAK LABEL

From: Date: Tue, 07 Mar 2006 18:14:16 +0000
Subject: Re: GOTO and/or BREAK LABEL
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Tue, 2006-03-07 at 12:58, John Coggeshall wrote:
> if($choice == 1) {
> 	goto bad;
> } else if ($choice == 2) {
> 	goto good;
> } else if ($choice == 3) {
> 	goto bad;
> } else if ($choice == 4) {
> 	goto good;
> }
> 
> good:
> 	$vote++;
> bad:
> 	return;

I don't remember, but I think Sarah Golemon allowed for it in one of her
patches way back:

<?php

$map = array
(
    1 => 'bad',
    2 => 'good',
    3 => 'bad',
    4 => 'acceptable',
);

goto $map[$choice];

good:
    vote += .5;

acceptable:
    vote += .5;

bad:
    return;

?>

For the record, I wouldn't normally fall through like that, but we're
just having fun :B

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'


Thread (106 messages)

« previous php.internals (#22220) next »