Linked Questions

Popular Questions

Here is the basics of my framework:

class CPU {

    public function load_class($class) {
        include_once($class . ".php");
        $this->$class = new $class;

    public function load_controller($class) {
        include_once($class . ".php");
        $class = new $class;

    public function run() {

        // Load DB class

        // Load controller

class About extends CPU {
    public function index() {

When run() is called to load the About class, accessing $DB gives the error below:

Fatal error: Call to a member function connect() on a non-object

I assume I need to use a singleton to create the class dynamically. CodeIgniter works in the same way but I can't work out what I have to do to amend my framework to make this work?

Related Questions