Hi,
I am new in php.I want to use goto statement inside my program.But when i execute the below coding the blank page appears.This is the example program i referred in site.
Coding:
goto a;
echo 'Foo';
a:
echo 'Bar';
Help me..
Thanks :-O
Hi,
I am new in php.I want to use goto statement inside my program.But when i execute the below coding the blank page appears.This is the example program i referred in site.
Coding:
goto a;
echo 'Foo';
a:
echo 'Bar';
Help me..
Thanks :-O
It means you don't have the latest version of php. The goto element is only available in the latest release (5.3) but I wouldn't recommend it due to incompatibility bugs. Instead try using loops and if statements such as the following:
<?php
if (false) {
echo 'Foo';
}
echo 'Bar';
?>
Please check which is the php version you are using.
The goto operator is available as of PHP 5.3.
There doesnt seem to be any errors in the code you are using. It should definitely be a problem with the version.
The goto operator is available only as of PHP 5.3
Please check your PHP version
goto is a throw-back to the 1960s and is generally considered a bad thing. It generated what is called spaghetti code and programmers are advised to avoid using it. It was a much loathed method of causing problems and has been expunged from almost all programming languages due to endless mis-use and abuse.
Use if, as suggested earlier or call a function rather than jumping to it and then returning. Or a switch / case set. Or anything else you can think of.
goto is a throw-back to the 1960s and is generally considered a bad thing. It generated what is called spaghetti code and programmers are advised to avoid using it. It was a much loathed method of causing problems and has been expunged from almost all programming languages due to endless mis-use and abuse.
Use if, as suggested earlier or call a function rather than jumping to it and then returning. Or a switch / case set. Or anything else you can think of.
Couldn't agree more. I used to use GOTO in VB when I was too lazy to code it properly (create functions). Of all the php I've ever written, I've never found the need to use a GOTO. Anybody know why it was introduced in 5.3?
Of all the php I've ever written, I've never found the need to use a GOTO. Anybody know why it was introduced in 5.3?
Mhh! as I was reading the post the same question came to my mind. Why would it be needed not only in PHP but also in other language like C++? Don't get mad at me cwarn (remember SHA1 cracker?)
That infamous gOtO ;)
Mhh! as I was reading the post the same question came to my mind. Why would it be needed not only in PHP but also in other language like C++? Don't get mad at me cwarn (remember SHA1 cracker?)
That infamous gOtO ;)
The reason I used the goto tag in c++ is because I was too lazy to make an infinit loop. But yes there are methods to use in any language which posses loops. I believe the goto tag was originally used before loops had been invented. But when new/current languages came out with the loop mechanism there was no need to use the goto unless your lazy or unexperienced.
I used to use GOTO in VB when I was too lazy to code it properly (create functions).
The reason I used the goto tag in c++ is because I was too lazy to make an infinit loop.
Mhh! Programmers are bunch of lazy people? Although don't use goto, I know I'm fond of those "lazy" shortcuts
Thank you to all
Prem2
Oh my. GOTO?
I havent heard that since the days of the VIC20, when you used to have to type in line numbers too :)
Zagga
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.