-3

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

提前感谢您的帮助。

4

1 回答 1

1

编辑:

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


前:

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

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

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

于 2013-02-23T05:16:12.673 回答