这是我的第二个问题,尽管我自己回答了上一个问题。不管怎样,我有一个 OOP 的基本问题,即如何从另一个类调用非静态方法。示例:我们在文件 A.class.php 中有一个名为 A 的类
class A {
public function doSomething(){
//doing something.
}
}
Run Code Online (Sandbox Code Playgroud)
另一个文件 B.class.php 上有一个名为 B 的第二个类
require_once 'A.class.php';
class B {
//Call the method doSomething() from the class A.
}
Run Code Online (Sandbox Code Playgroud)
我想现在一切都清楚了。如何:从类 A 调用 doSomething() 方法?