I wonder if something like this is possible in PHP
$goto = 'end';
goto $goto;
when I use it I get Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING
.
Furthermore, how would I do something like this (considering a()
returns true
or false
)
a() or goto end;
as opposed to the longer version
if (!a()) goto end;
Thanks so much!
- purely theoretically :)
Later edit: This has certainly got a lot of reaction. I think mentioning two of PHP's most debated areas (goto and eval) helped get some strong reactions. Anyway, I want to thank those who put in the effort to get past their "paranoia" (as somebody said in the comments). I especially want to thank DaveRandom and genesis for their answers.
Just to get things clear and put some people's hearts at ease: I know the reasons for not using goto. But to every "rule" there are exceptions.
As a final note, I'd like to understand the logic the person who actually voted down the question had. Is it not a valid question, is it not clear enough, could it have been easily answered by using a search engine? I guess I'll never have a motive for your action, "down-vote-user" :).
purely theoretically :)
– genesisbreak 3;
would do the same job... – DaveRandom