直接上代碼
<?php class example{ public static $pa; public $pb; public function __construct(){ $this->pb = ++self::$pa; } } $a = new example; $b = new example; echo $a->pb; echo '<hr/>'; echo $b->pb; ?>
本來想結果應該是
1 ----------------------------------------------------- 1
可是我錯了,正確的結果是
1 ---------------------------------------------------------------------------------- 2
基礎沒學好,趕快補補