Correcting teacher:灭绝师太
Correction status:qualified
Teacher's comments:
<?php
spl_autoload_register(function($class){
require $class.'.php';
});
class Player{
public $name = 'Jordan';
public $height;
public $team;
protected $playerNum;
public function __construct($name,$height,$team,$weight){
$this->name = $name;
$this->height = $height;
$this->team = $team;
$this->weight = $weight;
}
public function jog(){
return "$this->name is jogging, weighing $this->weight<br>";
}
public function shoot(){
return "$this->name is shooting, his height is $this->height<br>";
}
}
$np2 = new Player('kobe','206cm','Laker',"85kg");
echo $np2->name;
echo $np2->shoot();
class User
{
public static $name = '胡歌';
protected $_config = [
'auth_on'=>'true',
'auth_type'=>1,
];
public static $nation = "China";
private static $salary ;
static $count = 0;
public function __construct($name,$salary){
self::$name = $name;
self::$salary = $salary;
self::$count++;
}
public function getConfig(){
return sprintf('认证开关:%s<br>,认证类型:%d',$this->_config['auth_on'],$this->_config['auth_type']);
}
public static function getCount()
{
return sprintf('User类被实例化了%d次<br>',self::$count);
}
ECHO $user2->getCount();
echo User::getCount();
echo User::$name;
echo $user2->getConfig();