您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php面向对象有关问题?

2024/12/31 12:44:34发布22次查看
php面向对象问题???
class factory{
private $tmp=array();
function __construct(){}
public function t(){
array_push($this->tmp,3);
}
public function gett(){
return $this->tmp;
}
}
$a=new factory();
print_r($a->gett());
怎么输出null,我想输出3,怎么得到
------解决方案--------------------
...fuction t(){}
没有执行过 $tmp=array(); 他就是空数组
$a=new factory();
$a->t();
print_r($a->gett());
或者
function __construct(){
array_push($this->tmp,3);
}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product