2015-06-08 100 views
0

我得到致命錯誤:Laravel 5功能名稱必須是一個字符串錯誤

Function name must be a string

當嘗試return $redirect()->to(blah blah blah ...

if($act=="ban"){ 
     $ban_until = $request->input('ban_until'); 
     if(Ragnarok::temporarilyBan($account_id,$banned_by,$ban_until,$ban_reason)){ 
      return $redirect()->to('banlist'); 
     }else{ 
      return $redirect()->to('banlist')->withErrors('Failed to ban, database error'); 
     } 
    }else if($act=="unban"){ 
     if(Ragnarok::unBan($account_id,$banned_by,$ban_reason)){ 
      return $redirect()->to('banlist'); 
     }else{ 
      return $redirect()->to('banlist')->withErrors('Failed to unban, database error'); 
     } 
    } 

任何人面對這樣的錯誤?

+1

嘗試'重定向() - >到( 'banlist')'無'$' – haakym

回答

1

嘗試從功能刪除的$像這樣:

redirect()->to('banlist'); 

PHP函數必須以字母或下劃線開始,你已經錯誤地增加了一個$的功能。

從PHP文件:

Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*.

http://php.net/manual/en/functions.user-defined.php

2

redirect() Laravel中的函數不是變量,所以不需要$符號。

相關問題