Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Syntax error, unexpected T_STRING" problem with goto [closed]

http://www.faressoft.org/test/hello.php

My Code :

<?php
echo "hello World";
goto end; // this is line 3
echo "before end";
end:
echo "end";
?>

Error : Parse error: syntax error, unexpected T_STRING in /home/alfalah1/public_html/faressoft.org/test/hello.php on line 3

It works very well in my localhost but doesn't work in justhost server ? why ?

like image 383
faressoft Avatar asked Jan 25 '26 07:01

faressoft


1 Answers

but doesn't work in justhost server ? why ?

Probably because the remote server isn't running PHP 5.3, which is the minimum required version for goto.

That said, using the goto keyword is generally regarded as an awfully, awfully bad practice from the olden days. I still think this got introduced in PHP because of a lost bet or something. I would not get into the habit of using it.

like image 174
Pekka Avatar answered Jan 26 '26 20:01

Pekka