CodeIgniter 3/HMVC error on PHP 7.3

If you’re using HMVC or Codeigniter 3 on new PHP version i.e. 7.3, you might be seeing the following error:

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Quick Fix :

Just change application/third_party/MX/Router.php line 239

from this 

public function set_class($class)
    {
        $suffix = $this->config->item('controller_suffix');
        if (strpos($class, $suffix) === FALSE)
        {
            $class .= $suffix;
        }
        parent::set_class($class);
    } 

to this:

public function set_class($class)
    {
        $suffix = $this->config->item('controller_suffix');
        if( $suffix && strpos($class, $suffix) === FALSE)
        {
            $class .= $suffix;
        }
        parent::set_class($class);
    } 

Leave a Comment