3 回答

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

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超14個(gè)贊
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)注
- 545 瀏覽
添加回答
舉報(bào)