2014-01-27 52 views
0

我不斷收到此錯誤陣列意外啓動[

 
syntax error, unexpected '[' 

它是在該行下面的代碼片段1:

Route.php

 
Route::get('api/test/{input}', [ 
    'before' => 'checkauth', 
    "as" => "test", 
    "uses" => "[email protected]" 
]); 

有什麼不好?

+6

陣列文字語法'[1,2,3,4,5]'而不是較長語言構造'陣列(1,2, 3,4,5)'需要PHP 5.4+。你不能在5.3.3上使用它。 –

+1

您需要PHP/5.4才能使用[短陣列語法](http://es1.php.net/manual/en/migration54.new-features.php)。你顯然[需要PHP/5.3.7](http://laravel.com/docs/installation)來使用Laravel。你的PHP太老了。 –

回答

3

更改您的數組表示法。

Route::get('api/test/{input}', array(
    'before' => 'checkauth', 
    "as" => "test", 
    "uses" => "[email protected]" 
)); 
0

正如邁克爾Berkowski說,與[使用數組符號的需要PHP 5.4+

Php array documentation

由於PHP 5.4,你也可以使用短數組語法,它用[]替換array()。

應該使用array();符號:

Route::get('api/test/{input}', array(
    'before' => 'checkauth', 
    "as" => "test", 
    "uses" => "[email protected]" 
));