note 89884 deleted from control-structures.goto by thiago

From: Date: Fri, 27 Mar 2009 01:07:05 +0000
Subject: note 89884 deleted from control-structures.goto by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152506@lists.php.net to get a copy of this message
Note Submitter: Anonymous Coward ---- I'm wondering why this feature has been added to PHP. While I was writing insanely unmaintainable code with PHP 5.3 RC1 (just for fun ;)) I discovered that you can not use goto in eval() like this: <?php $label = 'foo'; eval("goto {$label};"); exit; foo: print 'Foo'; exit; bar: print 'Bar'; ?> Because that which is inside of eval() has its own scope. Imagine a huge PHP source file filled with dynamic labels and goto's. Something like: <?php $label = 'foo'; eval(<<<CODE goto {$label}; exit; foo: print 'Foo'; exit; bar: print 'Bar'; CODE ); ?> It's like the Divine Comedy written in PHP.

« previous php.notes (#152506) next »