【发布时间】:2019-07-05 21:25:47
【问题描述】:
我有主 index.php 文件,我可以在其中调用其他控制器,这很好。
我用call_user_func_array([$object, $this->method], $this->params);给他们打电话
例如,我首先包含控制器,然后调用它。我的控制器称为 IndexController,这是我如何包含并调用它的示例。
IndexController.php
<?php
class IndexController extends Controller {
function __construct()
{
print 'welcome to oxbir'."<BR>";
}
function index()
{
$this->view('panel/user');
}
}
控制器.php
<?php
class Controller
{
function __construct()
{
}
function view($view)
{
include('views/'.$view.'.php');
}
}
但我看到了这个错误...
致命错误:在第 3 行的 C:\xampp\htdocs\site\php\controllers\IndexController.php 中找不到类“控制器”
【问题讨论】:
-
您必须
include或require定义所需类的文件。所以你indexController.php一开始就需要require("Controller.php");。 -
我改了,但没有解决我的问题
-
所以请编辑您的问题以反映您所做的更改。
-
我的帖子改了,你现在可以看到了。
标签: php