0
我不斷收到此錯誤陣列意外啓動[
syntax error, unexpected '['
它是在該行下面的代碼片段1:
Route.php
Route::get('api/test/{input}', [ 'before' => 'checkauth', "as" => "test", "uses" => "[email protected]" ]);
有什麼不好?
我不斷收到此錯誤陣列意外啓動[
syntax error, unexpected '['
它是在該行下面的代碼片段1:
Route.php
Route::get('api/test/{input}', [ 'before' => 'checkauth', "as" => "test", "uses" => "[email protected]" ]);
有什麼不好?
更改您的數組表示法。
Route::get('api/test/{input}', array(
'before' => 'checkauth',
"as" => "test",
"uses" => "[email protected]"
));
正如邁克爾Berkowski說,與[
使用數組符號的需要PHP 5.4+
由於PHP 5.4,你也可以使用短數組語法,它用[]替換array()。
應該使用array();
符號:
Route::get('api/test/{input}', array(
'before' => 'checkauth',
"as" => "test",
"uses" => "[email protected]"
));
陣列文字語法'[1,2,3,4,5]'而不是較長語言構造'陣列(1,2, 3,4,5)'需要PHP 5.4+。你不能在5.3.3上使用它。 –
您需要PHP/5.4才能使用[短陣列語法](http://es1.php.net/manual/en/migration54.new-features.php)。你顯然[需要PHP/5.3.7](http://laravel.com/docs/installation)來使用Laravel。你的PHP太老了。 –