解析错误:语法错误,意外的T_STRING,找不到错误

问题描述:

上传后,此代码正常工作本地(xampp)我收到解析错误:语法错误,意外的T_STRING,但似乎无法找出什么是问题。解析错误:语法错误,意外的T_STRING,找不到错误

$user = $_GET["u"]; 
$order = $_GET["o"]; 

$fullorder = $user . $order . ".txt"; 

include("geoip.inc"); 
$ip=$_SERVER['REMOTE_ADDR']; 

function loghit() 
{ 
$user = $_GET["u"]; 
$order = $_GET["o"]; 

$fullorder = $user . $order . ".txt"; 
$lf_name = $fullorder; 


$monthly = 0; 

$monthly_path = "oldfiles"; 

$type = 1; 


$display = 1; 


$separator = "<br \>"; 


$log_file = dirname(__FILE__) . '/' . $lf_name; 


    $uIP = $_SERVER['REMOTE_ADDR']; 

    if (file_exists($log_file)) { 
     if (date('j') == 10) { 
      if (!file_exists($monthly_path)) { 
       mkdir($monthly_path); 
      } 

      $prev_name = $monthly_path . '/' . date("n-Y", strtotime("-1 month")); 
      if (!file_exists($prev_name)) { 
       copy($log_file, $prev_name); 

       if ($type == 0) { 
        $toWrite = "1"; 
        $info = $beforeAllText . "1"; 
       } else if ($type == 1) { 
        $toWrite = "1;" . $uIP . ","; 
        $info = $beforeUniqueText . "1"; 
       } else if ($type == 2) { 
        $toWrite = "1;1;" . $uIP . ","; 
        $info = $beforeAllText . "1" . $separator . $beforeUniqueText . "1"; 
       } 
       goto write_logfile; 
      } 
     } 

write_logfile文件中的代码进一步下跌:在这条线上发生

write_logfile: 
    //Put $toWrite in log file 
    file_put_contents($log_file, $toWrite); 

} 

错误:事先的任何帮助

   goto write_logfile; 

感谢。

+0

其中write_logfile在代码中定义.. ???你需要添加write_logfile标签.. – 2013-02-23 05:15:14

+3

我没有意识到人们实际上使用了'goto',因为它被引入 – 2013-02-23 05:16:02

+0

对不起,编辑了主帖。 – 2013-02-23 05:16:41

编辑:

goto命令仅在PHP> = 5.3.0可用。如果您尝试使用goto,则会发生意外的T_STRING错误。


BEFORE:

你需要在你的代码添加标签为goto到达。

http://php.net/manual/en/control-structures.goto.php

添加write_logfile:,你希望你的代码跳转到。

+0

这不在他的代码中吗? – 2013-02-23 05:20:40

+0

在他的编辑...是的。 – 2013-02-23 05:25:01

+0

这就是为什么人们必须确保服务器和本地上有正确的PHP版本... – Manatax 2013-02-23 05:28:29