<?php class A { public $param = "paramA"; public function test() { echo "testA"; } } class B extends A { public $param = "paramB"; public function test() { echo "testB"; } } $b = new B(); echo "$b->param = " . $b->param . "<br>"; $b->test(); ?>
输出:
paramB = paramB
testB
也就是说,通过继承与重载,相同的变量和函数被子类覆盖。