0
votes

I have main index.php file where i call other controllers and that is fine.

I call them with call_user_func_array([$object, $this->method], $this->params);

For example i first include controller and then i call it. My controller is called IndexController and this is example how i include it and call it.

IndexController.php

<?php

class IndexController extends Controller {

    function __construct()
    {
        print 'welcome to oxbir'."<BR>";
    }

    function index()
    {
        $this->view('panel/user');
    }
}

Controller.php

<?php

class Controller
{
    function __construct()
    {

    }

    function view($view)
    {
        include('views/'.$view.'.php');
    }
}

but I see this error...

Fatal error: Class 'Controller' not found in C:\xampp\htdocs\site\php\controllers\IndexController.php on line 3

1
You have to include or require the files where the required class is defined. So you indexController.php needs require("Controller.php"); at the begin.Kryptur
I changed it, but I did not solve my problemuser9975473
So please edit your question to reflect the changes you made.Kryptur
I changed my post, you can see now.user9975473

1 Answers

1
votes

Change

<?php

class IndexController extends Controller {

To

<?php
require_once('Controller.php');

class IndexController extends Controller {

You need to include the controller file or use some kind of autoload.