<?php class Counter { private static $count = 0; const VERSION = 2.0; function __construct() { self::$count++; } function __destruct() { self::$count--; } static function getCount() { return self::$count; } }; //创建一个实例,则__construct()将执行 $c = new Counter(); //输出 1 print(Counter::getCount() . "<br>n"); //输出类的版本属性 print("Version used: " . Counter::VERSION . "<br>n"); ?>