分析错误:语法错误,意外的T_STRING,可以';找不到错误


Parse error: syntax error, unexpected T_STRING, can't find the error

上传后,此代码在本地(examplep)运行良好。我收到解析错误:语法错误,意外的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;

提前感谢您的帮助。

编辑:

goto命令仅在PHP>=5.3.0中可用。如果尝试以其他方式使用goto,则会出现意外的T_STRING错误。


之前:

您需要在代码中添加一个标签,以便goto能够访问。

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

write_logfile:添加到您希望代码跳转到的位置。