php - 如何在php中使用继承来实例化带有函数的函数
问题描述
是否可以使用继承在另一个函数中回显一个函数?请教我怎么做?
<?php
class Clinic extends Patient{
function getPatientsInfo(){
echo $this->GeneralInfo();
}
}
$patient = new Clinic;
$patient->getPatientsInfo();
解决方案
如果 GeneralInfo() 在 Patient 类中是公共的或受保护的,那么您可以使用。
推荐阅读
- casting - 为什么从对 c_void 指针的引用进行强制转换需要双重强制转换?
- javascript - 删除选择的直接父节点 ( )
- android - 如何编写 JUnit 测试以确保 Arraylist
记录正确吗? - javascript - 是否可以在 Javascript 中使用 Linq 替换字符?
- kubernetes - 如何将 Kubernetes 与 Gitlab 集成
- r - R中循环中的字符序列匹配
- android - 如何检查用户是否点击了屏幕的特定部分?
- javascript - 在脚本中更改 HTML 中输入框的值
- dart - Dart / flutter:DropdownButton在值更改时导致异常
- jsp - JSP - 内联 JS 压缩/缩小