<?php
class User
{
public $name;
public $score;
private static $count = 0;
public function __construct($name, $score)
{
$this->name = $name;
$this->score = $score;
User::$count++;
}
public static function getUserCount()
{
return User::$count;
}
}
$user1 = new User("Taro", 70);
$user2 = new User("Jiro", 90);
//User::$count++;
//echo User::$count . PHP_EOL;
echo User::getUserCount() . PHP_EOL;