Laravel 5函数名称必须是字符串错误 [英] Laravel 5 Function name must be a string bug

查看:372
本文介绍了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');
        }
    }

有人面对这个错误吗?

推荐答案

尝试从函数中这样删除$:

Try removing the $ from the function as so:

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

PHP函数必须以字母或下划线开头,这是您在函数中误加了$.

PHP functions must begin with a letter or underscore, you have mistakenly added a $ to the function.

来自PHP文档:

函数名称遵循与PHP中其他标签相同的规则.一个有效的 函数名称以字母或下划线开头,后跟任意 字母,数字或下划线的数量.作为正则表达式, 因此可以表示为:[a-zA-Z_ \ x7f- \ xff] [a-zA-Z0-9_ \ x7f- \ xff] *.

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- define.php

这篇关于Laravel 5函数名称必须是字符串错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆