【发布时间】:2017-02-06 17:46:44
【问题描述】:
这是我的代码:
这行得通:
<?php
private $controller;
public function __construct() {
}
public function randomFunc() {
$this->controller = new Controller();
return $this->controller;
}
?>
不起作用:
<?php
private $controller;
public function __construct() {
$this->controller = new Controller();
}
public function randomFunc() {
return $this->controller;
}
?>
如您所见,当我在函数中分配 $controller = new Controller() 时,它可以工作,但是当我在构造中执行它时,它不起作用。怎么会?谢谢
【问题讨论】:
-
发布您的完整代码,包括该类以及您正在使用的任何包含/要求。
-
@Fred-ii- 这几乎是完整的代码。我正在使用 mvc,所以在它到达这个文件之前需要来自文件。
标签: php performance function model-view-controller constructor