时间:2021-07-01 10:21:17 帮助过:5人阅读
求教。
求教。
冒昧猜下楼主的用意吧:
- <code>class Man{
- private $_name;
- private $_age;
- public function __construct($name, $age) {
- $this->_name = $name;
- $this->_age = $age;
- }
- public function getName() {
- return $this->_name;
- }
- }</code>
@paul5 你都没有给 _age
或者 _name
赋值,取出来当然是空了。看你的代码只是给 name
与 age
赋值了,少写了下划线?
construct里面是$this->name;
getName里面是$this->_name;
下划线忘写了