<?php
class Person{
public function __construct(){
return $this->run();
}
}
class Me extends Person{
public function run(){
echo "I'm running";
}
public function jump(){
$pass = "悄悄跳";
}
}
$me = new Me(); # 为父类与子类的融合,
$me->jump();
# 输出:I'm running
<?php
class Person{
public function __construct(){
return 'Person<br/>';
}
}
class Me extends Person{
public function __construct(){
$parent = parent::__construct();
return $parent.' Me <br/>';
}
}
$me = new Me();
$res = $me->__construct();
echo $res;
# 输出:Person
# Me
# 实例化后调用方法,子类覆盖父类
# 同时子类中parent::__construct()依旧具有意义