note 118188 added to control-structures.goto

From: Date: Fri, 23 Oct 2015 02:10:36 +0000
Subject: note 118188 added to control-structures.goto
Groups: php.notes 
Request: Send a blank email to php-notes+get-204006@lists.php.net to get a copy of this message
This works good: <?php goto start; five: echo $i; goto end; start: echo 'I have '; for ($i=0; $i < 10; $i++) { if ($i == 5) { goto five; } } end: echo ' apples'; ?> Output: I have 5 apples. This don't work: <?php goto start; five: echo $i; goto end; start: echo 'I have '; $count(); end: echo ' apples'; $count = function () { for ($i=0; $i < 10; $i++) { if ($i == 5) { goto five; // line 18 } } } ?> PHP Fatal error: 'goto' to undefined label 'five' on line 18 ---- Server IP: 72.52.91.14 Probable Submitter: 177.242.137.91 ---- Manual Page -- http://php.net/manual/en/control-structures.goto.php Edit -- https://master.php.net/note/edit/118188 Del: integrated -- https://master.php.net/note/delete/118188/integrated Del: useless -- https://master.php.net/note/delete/118188/useless Del: bad code -- https://master.php.net/note/delete/118188/bad+code Del: spam -- https://master.php.net/note/delete/118188/spam Del: non-english -- https://master.php.net/note/delete/118188/non-english Del: in docs -- https://master.php.net/note/delete/118188/in+docs Del: other reasons-- https://master.php.net/note/delete/118188 Reject -- https://master.php.net/note/reject/118188 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#204006) next »