2015-06-08 102 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中的函数不是变量,所以不需要$符号。

相关问题