解析错误:语法错误,意外的'$ new_qgs_layer'(T_VARIABLE)

时间:2019-10-07 10:23:16

标签: php laravel

我遇到此错误:

  

解析错误:语法错误,意外的'$ new_qgs_layer'(T_VARIABLE)

我不明白为什么。启动函数时,我将变量$new_qgs_layer定义为null,并用它来存储str_replace函数的返回值。

我的PHP代码:

public function makeLayer () {
    $current_session = $request->session()->get('key');

    $value[] = "3";
    $value[]= Imput::get('component');
    $value[] = "flux_balance";

    $search[] = "ID_SCENARIO";
    $search[] = "ID_COMPONENT";
    $search[] = "MYVARIABLE";

    $qgs_layer = file_get_contents("carbone_test.qgs");
    $new_qgs_layer = null;

    if ($qgs_layer === false) {
        return null;
    }
    $file_name = $current_session + "_layer"
    $new_qgs_layer = str_replace($search, $value, $qgs_layer);
    file_put_contents($file_name, $qgs_layer_new);

    return Response::json($file_name,200);
}

1 个答案:

答案 0 :(得分:2)

T_VARIABLE通常在您错过需要分号的地方时发生。在您的函数中,您错过了此行之后的;

$file_name = $current_session + "_layer";