如果b里面想使用a里面的$time
变量应该怎么办呢?
public function a(){
$time='1520452015';
return $this->fetch();
}
public function b(){
}
如果b里面想使用a里面的$time
变量应该怎么办呢?
public function a(){
$time='1520452015';
return $this->fetch();
}
public function b(){
}
封装
了解下
public $time = '1520452015';
public function a()
{
$time = $this->time;
return $this->fetch();
}
public function b()
{
var_dump($this->time);
}
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);
}
1 回答4.1k 阅读✓ 已解决
3 回答1.9k 阅读✓ 已解决
2 回答2.3k 阅读✓ 已解决
2 回答780 阅读✓ 已解决
1 回答1.4k 阅读✓ 已解决
2 回答2.3k 阅读
1 回答940 阅读✓ 已解决
$time
作为返回参数返回出去$this->time