class Counter {
private static int $count = 0;
public function __construct() {
self::$count++;
}
public static function getCount(): int {
return self::$count;
}
}
new Counter();
new Counter();
echo Counter::getCount(); // → 2 class Counter {
private static int $count = 0;
public function __construct() {
self::$count++;
}
public static function getCount(): int {
return self::$count;
}
}
new Counter();
new Counter();
echo Counter::getCount(); // → 2