CodeIgniter Forums
Call to a member function X() on null - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Call to a member function X() on null (/showthread.php?tid=76536)



Call to a member function X() on null - officialfreeway - 05-22-2020

I am using CI 3.0.4 HMVC that supports 3.x CI The ERROR i got: 
An uncaught Exception was encountered
Type: Error
Message: Call to a member function display_games() on null
Filename: C:\xampp\htdocs\pda-projekt_GERGEL\application\modules\Admin\controllers\Admin.php
Line Number: 18
Backtrace:
File: C:\xampp\htdocs\pda-projekt_GERGEL\index.php
Line: 292
Function: require_once


Admin.php:

Code:
<?php

class Admin extends MY_Controller
{
function __construct()
{
parent::__construct();
$this->load->module('Games');
}

function index()
{
$this->template->call_admin_template();
}

function games()
{
$this->games->display_games(); //LINE 18
}
}

THIS IS Games/Controller/Games.php where i call display_games function:

Code:
<?php

class Games extends MY_Controller
{
     function __construct()
    {
        parent::__consturct();
    }

    function display_games()
    {
        $this->template->call_admin_template();
    }
}