FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » terminate a PHP script
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: terminate a PHP script [message #172569 is a reply to message #172535] Tue, 22 February 2011 00:28 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
sheldonlg wrote:
> On 2/21/2011 12:06 PM, Denis McMahon wrote:
>> On 21/02/11 16:51, n00m wrote:
>>>> No, you should not use goto! It causes more problems than it solves.
>>>
>>> Why on the earth???
>>> "goto" can produce 10000 empty lines in no time. Like this:
>>
>> Because there is no structure to a program that uses goto. When it fails
>> to work properly (and it will) it can become impossible to see how it
>> arrived at the point that it fails at.
>>
>>> $cnt = 0;
>>>
>>> mm:
>>> ++$cnt;
>>> echo '<BR>';
>>> if ($cnt< 10000) goto mm;
>>
>> Your goto method uses 5 lines. A while loop uses 2:
>>
>> $i = 10000;
>> while ($i--) echo "<br>\n";
>>
>> and a for loop only 1:
>>
>> for ($cnt = 10000; $cnt--;) echo "<br>\n";
>>
>> or:
>>
>> for ($cnt = 0; $cnt< 10000; $cnt++) echo "<br>\n";
>>
>> Rgds
>>
>> Denis McMahon
>
> I fully agree about gotos. There is NO need for them. What is wrong
> with this pseudocode?
>
> ===========
> if (passes test for failure condition) {
> ... all the rest of the code for success that is already there
> --- except the footer
> }
>
> footer stuff.
> ==========
>
> All it does is add two lines (the if test and a closing brace) and one
> level of indentation, and it does what the OP wants.
>
> Since seeing the if-then-else first appear in Fortran circa 1980, I have
> never used a single goto in any language in which I have coded.
>
Well that's cos you never wrote Assembler :-)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Extralight browser-webserver communication via cookies (+)
Next Topic: Storing multiple character set types (or a representation of em) in a table column
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Jul 05 18:04:00 GMT 2024

Total time taken to generate the page: 0.04163 seconds