我是面向对象编程的新手。
我的问题是,我在类方法中包含一个文件。
现在我怎么能在所需的文件内使用类方法?我用$this->two()
,它工作正常,但我不认为这是最好的方法。如果其他人正在阅读代码,他将很难理解代码。
对此有何种选择?在类中使用包含文件的类方法
//Main.php
class Test{
public function one(){
....
require('file.php');
}
public function two(){
....
}
public function three(){
....
}
}
?>
//file.php
<div>
<?php $this->two(); ?>
</div>