时间:2021-07-01 10:21:17 帮助过:2人阅读
trait Counter {
static $a = 5;
public function inc() {
static $c = 0;
$c += 1;
echo "$c
";
}
}
class C1 {
use Counter;
}
class C2 {
use Counter;
}
$o = new C1();
$o->inc();
echo Counter::$a;
echo '
';
$p = new C2();
$p->inc();
?>