-2

I have this error :

Parse error: syntax error, unexpected '$new_qgs_layer' (T_VARIABLE)

And I don't understand why. When I start the function I defined the variable $new_qgs_layer to null and I use it to stock the return of str_replace function.

My PHP code :

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);
}
Rashed Hasan
  • 3,721
  • 11
  • 40
  • 82
SebCollard
  • 332
  • 2
  • 20

1 Answers1

2

T_VARIABLE usually occurs when you miss the semi-colon where it is required. In your function, you have missed the ; after this line.

$file_name = $current_session + "_layer";
Zain Farooq
  • 2,956
  • 3
  • 20
  • 42