考虑以下代码:
class Upper {
private $lower;
function __construct($passme1, $passme2) {
if(!class_exists("Lower")) {
include 'path/to/file.php';
}
$this->lower = new Lower($passme1, $passme2);
}
//functions
public function foo() {
//queries database and returns user specific information
}
}
在链接文件中,我有Lower类:
class Lower {
function __construct($passme1, $passme2) {
//sort the passed variables out
}
public function bar() {
//trying to access the public function foo of class Upper
}
}
我发现自己需要从 Lower 类的函数栏中访问 Upper 类的函数 foo。
这是可能吗?
谢谢你,
乔