子类父类不在同一个文件

pingheguo pingheguo 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我的父类写在class.php中如下
<?php
class BaseClass {
function __construct() {
print "In BaseClass constructor\n"."<br>";
}
}

?>

继承类写在SubClass.php中
<?php
class SubClass extends BaseClass {
function __construct() {
parent::__construct();
print "In SubClass constructor\n";
}
}
$obj =new SubClass();
?>
在SubClass.php中
没有使用
include("class.php");是无法的执行的。

---------------------------------------

但是我见别人的源码都没有include("class.php");这句啊。
还有没有别的办法呢?
...全文
评论 11
收藏 已收藏
分享
返回顶部
pingheguo
基础编程 21,889 成员 140,329 内容