日期:2014-05-17 浏览次数:20555 次
<?php
trait Counter {
static $a = 5;
public function inc() {
static $c = 0;
$c += 1;
echo "$c<br />";
}
}
class C1 {
use Counter;
}
class C2 {
use Counter;
}
$o = new C1();
$o->inc();
echo Counter::$a;
echo '<br />';
$p = new C2();
$p->inc();
?>