자주 안썼더니 계속 까먹는다 땅콩도 아닌데
별수 없다 매일은 아니더라도 자주 상기시키자....
에공 힘들다.
<?php
class Person{
private static $count = 0;
private $name;
function __construct($name){
$this->name = $name;
self::$count++;
}
function print(){
echo "<h3>".$this->name."[".self::$count."]</h3>";
}
function getCount(){
return self::$count;
}
}
$p1 = new Person('hoho');
$p1->print();
$p2 = new Person('thisme');
$p2->print();
$p3 = new Person('nonofg');
$p3->print();
echo Person::getCount();
?>
소스는 생활코딩 소스...