受保护的继承后可以访问,私有的只能在该类中访问,不会被继承访问
class Man{
protected $name='lee';//受保护
private $age=123;//私有
function __construct(){
echo $this->name;//lee
echo $this->age;//123
}
}
class Girl extends Man{
function __construct(){
echo $this->name;//lee
echo $this->age;//不会出现123,
}
}
new Man();
new Girl();
<?php
class Man{
protected $name='lee';//受保护
private $age=123;//私有
function __construct(){
echo $this->name;//lee
echo $this->age;//123
}
}
class Girl extends Man{
function __construct(){
echo $this->name;//lee
echo $this->age;//不会出现123,
}
}
new Man();
new Girl();