出现这个错误信息的原因是在静态方法中使用$this来调用本类的方法,在php中,静态方法调用使用self。代码如下
public static function editPlaceSelect($places=[], $city_id=-1){ if(is_array($places) && count($places)>0){ foreach ($places as $place){ $this->areaPlace($city_id, $place['area_id'], $place['address']); } }else{ echo '
红色代码处应改为:
self::areaPlace($city_id, $place['area_id'], $place['address']); $this->areaSelect($city_id, $area_id);
以上就介绍了Using $this when not in object context错误信息,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。