<?php
class MyObject {
function myMethod() {
//标准功能
echo "Standard Functionality\n";
}
}
class MyOtherObject extends MyObject {
function myMethod() {
//添加一些新功能
echo "New Functionality\n";
//然后再调用MyObject中定义的原来的myMethod方法
parent::myMethod();
}
}
$obj = new MyotherObject();
$obj->myMethod(); //New Functionality Standard Functionality
时间: 2024-10-18 11:59:48