Non-static method think\Url::build() should not be called statically, assuming $this from incompatib


ThinkPHP框架错误提示:

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

我们在使用ThinkPHP框架的时候可能经常会出现这样的问题,错误意思是:非静态方法不能静态调用,非静态方法指的是上述错误中的“think\Url::build()”方法,要解决这个问题一般两个简单的处理,我这里就以Url类为例做修改,其它类方法都是一样的解决办法。

1、打开类文件,将要使用的方法,比如:Url类下的build()方法改成静态方法如下:(public static function())

publick static builder(){
//代码段
}

2、先实例化类,然后再调用方法如下:

$url = new Url();
$build = $url->build('admin/widget.images/index',array('fodder'=>'image'));

这样就解决了这个问题。


注:本文转载自唯马网络,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如有侵权行为,请联系我们,我们会及时删除。

评论