解决TP5.1 报错:Non-static method think\Cookie::get() should not be called statically...

心已赠人 2022-03-15 02:20 919阅读 0赞

在Controller类中获取Cookie时完整的报错:

Non-static method think\Cookie::get() should not be called statically, assuming $this from incompatible context

百度翻译过来的意思:假设$this来自不兼容的上下文,则不应静态调用非静态方法think\cookie::get()。

原本的在Controller类中,获取Cookie时是用静态方法获取的:

  1. Cookie::get('name');

改成用助手函数获取就好了:

  1. cookie('name');

发表评论

表情:
评论列表 (有 0 条评论,919人围观)

还没有评论,来说两句吧...

相关阅读