note 91795 deleted from control-structures.goto by danbrown
| From: | danbrown@php.net | Date: | Thu, 25 Jun 2009 18:18:04 +0000 |
| Subject: | note 91795 deleted from control-structures.goto by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-157505@lists.php.net to get a copy of this message | ||
Note Submitter: concerned_citizen at example dot com
----
For all the new programmers out there learning PHP, the computer science establishment has a simple
rule regarding goto statements. The rule is to not use them. Ever.
goto statements become problematic very quickly because using even one can make auditing the path of
execution through your script extremely difficult. A much, much better solution is to define logical
pieces of work in functions and call them as needed.
Programs with goto statements typically devolve rapidly into systems where global variables abound,
and random parts of the script have seemingly random and unpredictable side effects on other parts
of the script. Kind of like whack-a-mole. A graphical representation of your code with goto
statements will look less like a highway system and more like the bumper cars at the state fair.
Consider yourself warned.
Besides, you don't want to be attacked by dinosaurs, do you?