CodeIgniter & get_instance () not working in php5.6 version?

My codeigniter site works correctly in php5.4 version but when I update my php version to php5.6.30 it doesn't work.

function &get_instance()
{       
    return CI_Controller::get_instance();
}

      

The above function is on line 233 of my file and returns null values.

Error - Fatal error: Class 'CI_Controller' not found in Coginiter_site \ system \ core \ CodeIgniter.php on line 233

I traced the point of error - Code under system / core / common.php

if ( ! function_exists('load_class'))
{
    function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
    {
        static $_classes = array();

        // Does the class exist?  If so, we're done...
        if (isset($_classes[$class]))
        {
            return $_classes[$class];
        }

        $name = FALSE;

        // Look for the class first in the local application/libraries folder
        // then in the native system/libraries folder
        foreach (array(APPPATH, BASEPATH) as $path)
        {
            if (file_exists($path.$directory.'/'.$class.'.php'))
            {
                $name = $prefix.$class;

                if (class_exists($name) === FALSE)
                {
                    require($path.$directory.'/'.$class.'.php');
                }

                break;
            }
        }

        // Is the request a class extension?  If so we load it too
        if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'))
        {
            $name = config_item('subclass_prefix').$class;

            if (class_exists($name) === FALSE)
            {
                require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php');
            }
        }

        // Did we find the class?
        if ($name === FALSE)
        {
            // Note: We use exit() rather then show_error() in order to avoid a
            // self-referencing loop with the Excptions class
            exit('Unable to locate the specified class: '.$class.'.php');
        }

        // Keep track of what we just loaded
        is_loaded($class);

        $_classes[$class] = new $name();
        return $_classes[$class];
    }
}

      

returns an empty result This line creates a problem $ _ classes [$ class] = new $ name (); Please, check him.

+3


source to share


2 answers


You can try with this , change on line CodeIgniter.php 75

set_error_handler('_exception_handler');

      

to

set_exception_handler('_exception_handler');

      

Update:



If that doesn't work, maybe you can check other things:

  • Check if the DB error is (this is strange, but sometimes the DB error is displayed as "CI_Controller not found", for example with a bad db name).
  • Check if the change is changing: $config['log_threshold'] = 0;

    for you
  • Reinstall the entire CI system system folder.

Here and here have the same problem, you can check all the answers.

If none of these functions work, try sending some code and context to your controller.

Hope it helps!

+1


source


Can you follow the first solution ? Hope this clears up your problem.



+2


source







All Articles