phpclass father{ //定义father类//定义private修饰的类成员和方法private $hair='curly hair';private function smoke(){echo '我有吸烟的习惯。';}}class son extends father{ //定义继承自father类的son类//定义访问private修饰的类成员的方法public function get_property(){$this->hair;$this->smoke();}}$son=new son(); //实例化son类的对象$son->get_property(); //调用对象的方法 ?>