【php开源代码栏目提醒】:网学会员在php开源代码频道为大家收集整理了code3.21.php提供大家参考,希望对大家有所帮助!
<?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;
}
};
$c = new Counter();//创建一个实例,执行构造函数
print("输出的值为:".Counter::getCount() . "<br>");//输出 1
print("类的版本号: " . Counter::VERSION . "<br>");//输出类的版本属性
?>