嘗試從一個方法中獲取一些數據在側靜態方法(使用它在一個其他類中),但我得到'使用$ this當不在對象上下文.. '錯誤。試圖訪問其他類中的一個類的數據
下面一個基本的例子
class mClass{
public $someVar = 'Hello world...';
public function passFunc(){
$give = $this->someVar;
return $give;
}
public static function showFunc(){
$show = self::passFunc();
return $show;
}
}
mClass::showFunc();// show error: Using $this when not in object context in...
'$ MyClass的=新mClass;'? http://www.php.net/manual/en/keyword.class.php –