如果b里面想使用a里面的$time变量应该怎么办呢?
public function a(){
$time='1520452015';
return $this->fetch();
}
public function b(){
}
4 回答
精慕HU
TA贡献1845条经验 获得超8个赞
封装
了解下
public $time = '1520452015';
public function a()
{
$time = $this->time;
return $this->fetch();
}
public function b()
{
var_dump($this->time);
}
长风秋雁
TA贡献1757条经验 获得超7个赞
private $time = 'xxxxx';
public function a()
{
$time = $this->time;
return $this->fetch();
}
public function b()
{
dump($this->time);
}
private static $time = 'xxxxx';
public function a()
{
$time = self::$time;
return $this->fetch();
}
public function b()
{
dump(self::$time);
}
- 4 回答
- 0 关注
- 1437 浏览
添加回答
举报
0/150
提交
取消