note 89884 added to control-structures.goto

From: Date: Fri, 27 Mar 2009 01:01:22 +0000
Subject: note 89884 added to control-structures.goto
Groups: php.notes 
Request: Send a blank email to php-notes+get-152505@lists.php.net to get a copy of this message
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. ---- Server IP: 195.207.10.20 Probable Submitter: 81.244.222.170 ---- Manual Page -- http://www.php.net/manual/en/control-structures.goto.php Edit -- https://master.php.net/note/edit/89884 Del: integrated -- https://master.php.net/note/delete/89884/integrated Del: useless -- https://master.php.net/note/delete/89884/useless Del: bad code -- https://master.php.net/note/delete/89884/bad+code Del: spam -- https://master.php.net/note/delete/89884/spam Del: non-english -- https://master.php.net/note/delete/89884/non-english Del: in docs -- https://master.php.net/note/delete/89884/in+docs Del: other reasons-- https://master.php.net/note/delete/89884 Reject -- https://master.php.net/note/reject/89884 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152505) next »