Re: Problems w/ goto
| From: | Robert Cummings | Date: | Fri, 17 Dec 2010 17:22:13 +0000 |
| Subject: | Re: Problems w/ goto | ||
| References: | 1 2 3 | Groups: | php.db php.general |
| Request: | Send a blank email to php-db+get-47549@lists.php.net to get a copy of this message | ||
On 10-12-17 12:08 PM, Steve Staples wrote:
On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote:I was one of the people that argued in favour of GOTO on the Internals list a few years ago. GOTO has a use, and a very good one at that. It is by far the most efficient construct when creating parsers or other similar types of logic flow. The demonized GOTO of the 80s was primarily due to jumping to arbitrary points in the code, or in the case of basic to arbitrary line numbers in the code which had little meaning for future readers. When used properly within a well defined scope and with well named labels, GOTO can be a superior choice. If you think GOTO doesn't exist in many types of software, you need only grep for it in the C source code for PHP, MySQL, and Apache. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized.[snip] Thank you with your excellent help in the past. Here is another puzzler.... I am trying to write a program that can have two(2) independent forms in one PHP file. When I run the code below [from PHP - A Beginner's Guide], to which I have added a second form, it freezes. Without the goto statements, it runs. When it does run, it displays both forms on one Web screen. What I desire is for the first form to be displayed, the data entered and then the second form displayed. In an actual, not test program like this one, the data in the second form would be dependent on the first form. What did I do wrong? [/snip] You used GOTO. In this case I would recommend using something like jQuery to 'hide' one form until the other form is complete. PHP has sent the output to the browser already, both forms are there and display when you remove the GOTO. GOTO should never be used like this. GOTO should never be used.Wow... that brought me back to 1990... using basic and batch files... I honestly didn't even know that the GOTO was still in existence, especially within PHP. I had to show the people in my office, and we all got a chuckle from teh XKCD comic in the PHP documentation for GOTO http://ca2.php.net/goto Steve