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

时间:2013-02-23 05:12:48

标签: php

此代码在上传后工作正常(xampp)我收到Parse错误:语法错误,意外的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;

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

修改

goto命令仅在PHP&gt; = 5.3.0中可用。如果您尝试使用goto,则会出现意外的T_STRING错误。


<强> BEFORE:

您需要在代码中添加标签goto才能到达。

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

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