3 回答

TA貢獻1875條經(jīng)驗 獲得超3個贊
public function foobarfunc() { return $this->foo();}
foobar::foobarfunc();
static
)$this
.
不應(yīng)對非靜態(tài)方法使用靜態(tài)調(diào)用。 靜態(tài)方法(或靜態(tài)調(diào)用的方法)不能使用$this,它通常指向類的當(dāng)前實例,因為在使用靜態(tài)調(diào)用時沒有類實例。
$foo
$foobar = new foobar();$foobar->foobarfunc();
這個 剖面 而 一頁。
__construct
global $foo;
global
$foo
$foo
$foo
$this->foo

TA貢獻1817條經(jīng)驗 獲得超14個贊
foobarfunc
::
$this
$this
E_STRICT
Strict Standards: Non-static method foobar::foobarfunc() should not be called statically
$fb = new foobar;echo $fb->foobarfunc();
global
- 3 回答
- 0 關(guān)注
- 525 瀏覽
添加回答
舉報