物件向下傳遞特性
當一個物件呼叫一個實例方法,然後再該方法中又去靜態呼叫另一個類別的方法,則在被靜態呼叫的方法中獲得來源方法中的物件(this )
<code><span><span><?php </span><span><span>class</span><span>bee</span>{</span><span>public</span><span>$a</span> = <span>1</span>; <span>public</span><span><span>function</span><span>f</span><span>()</span>{</span><span>echo</span><span>$this</span>->a; <span>echo</span><span>'<br>'</span>; @lig::f(); } } <span><span>class</span><span>lig</span>{</span><span>public</span><span>$a</span> = <span>2</span>; <span>public</span><span><span>function</span><span>f</span><span>()</span>{</span><span>echo</span><span>$this</span>->a; } } <span>$obj</span> = <span>new</span> bee(); <span>$obj</span>->f();</span></span></code>
static 後期靜態綁定
static有3個不同意義的語法
<code><span><span>function</span><span>f</span><span>()</span>{</span><span>static</span><span>$v</span> = <span>1</span>; }</code>
封裝
就是把資料封裝起來盡量不給別人看,可以認為最基本的封裝是把很多的資料封裝類別裡面,但更嚴格地講,是盡量將屬性做成私有的,並透過共有的方法向外提供操作。多態繼承