我有两个类相同的PHP和一些相同的功能

时间:2016-12-14 09:18:29

标签: php

我有两个同名的班级, 我需要使用第二类扩展第一类 当调用任何函数时,第二类中的所有函数都执行父函数并传递相同的参数。

示例:

// classA.php

<?php
class first{
    function print_me(){
        echo "me";
        echo "<br>";
    }
}
//classB.php
class_alias("first","first_orgin",true);
class first_new extends first_orgin{
    function print_me(){
        parent::print_me();
        echo "me_child";
        echo "<br>";
    }
}
?>

include_once "classA.php";

include_once "classB.php";

use first_new as  first;

0 个答案:

没有答案
相关问题