首页 > 解决方案 > 如何在php中使用继承来实例化带有函数的函数

问题描述

是否可以使用继承在另一个函数中回显一个函数?请教我怎么做?

<?php
class Clinic extends Patient{

    function getPatientsInfo(){

        echo $this->GeneralInfo();

    }
}
$patient = new Clinic;
$patient->getPatientsInfo();

标签: phpfunctioninheritance

解决方案


如果 GeneralInfo() 在 Patient 类中是公共的或受保护的,那么您可以使用。


推荐阅读