请问有没有人用过traits类型?有个问题需要问
<br /> <?php<br /> trait Counter {<br /> static $a = 5;<br /> public function inc() {<br /> static $c = 0;<br /> $c += 1;<br /> echo "$c<br />";<br /> }<br /> }<br /> <br /> class C1 {<br /> use Counter;<br /> }<br /> <br /> class C2 {<br /> use Counter;<br /> }<br /> <br /> <br /> <br /> $o = new C1();<br /> $o->inc();<br /> echo Counter::$a;<br /> echo '<br />';<br /> <br /> $p = new C2();<br /> $p->inc();<br /> ?><br />