goto的“语法错误,意外的T_STRING”问题

时间:2010-11-09 13:52:30

标签: php string syntax goto

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

我的代码:

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

错误: 解析错误:语法错误,第3行/home/alfalah1/public_html/faressoft.org/test/hello.php中的意外T_STRING

它在我的localhost中工作得很好但在justhost服务器上不起作用?为什么?

1 个答案:

答案 0 :(得分:9)

  

但在justhost服务器中不起作用?为什么?

可能是因为远程服务器没有运行PHP 5.3,这是goto的{​​{3}}。

也就是说,使用goto关键字通常被认为是从以前开始的非常糟糕的做法。我仍然认为这是因为丢失赌注或其他东西而在PHP中引入的。我不会养成使用它的习惯。