Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel 5函数名必须是字符串错误_Php_Laravel 5 - Fatal编程技术网

Php Laravel 5函数名必须是字符串错误

Php Laravel 5函数名必须是字符串错误,php,laravel-5,Php,Laravel 5,我得到一个致命错误: 函数名必须是字符串 当尝试将$redirect()->返回到(诸如此类) if($act=="ban"){ $ban_until = $request->input('ban_until'); if(Ragnarok::temporarilyBan($account_id,$banned_by,$ban_until,$ban_reason)){ return $redirect()->to('ban

我得到一个致命错误:

函数名必须是字符串

当尝试
将$redirect()->返回到(诸如此类)

    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');
        }
    }

有人遇到此错误吗?

redirect()
是Laravel中的函数,不是变量,因此不需要
$
符号。

尝试从函数中删除
$
,如下所示:

redirect()->to('banlist');
PHP函数必须以字母或下划线开头,因为您错误地在函数中添加了
$

从PHP文档:

函数名遵循与PHP中其他标签相同的规则 函数名以字母或下划线开头,后跟任意 字母、数字或下划线的数目。作为正则表达式, 可以这样表达:[a-zA-Z\ux7F-\xff][a-zA-Z0-9\ux7F-\xff]*

在不使用
$