Meskjei
2016-07-13 23:51
<?php
class nbaPlayer{
// public $name;
//public $team;
function __construct($name,$team){
$this->name = $name;
$this->team = $team;
}
public function name(){
echo "球员名:".$this->name."\n";
}
public function team(){
echo "球队名:".$this->team."\n";
}
}
$James = new nbaPlayer('James','Cavaliers');
$James->name();
$James->team();
?>
注释掉的是属性,而你输出调用的是方法,因为用了构造函数。
PHP面向对象编程
70146 学习 · 361 问题
相似问题