Codeigniter 3 HMVC 已被破坏

Ami*_*min 4 php codeigniter hmvc codeigniter-3

在 Codeigniter 中使用这个 HMVC 插件。( https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/src/codeigniter-3.x/ )

在另一台服务器上运行良好,但在这台服务器上我收到此错误!

A PHP Error was encountered

Severity: 8192

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

Filename: MX/Router.php

Line Number: 239

Backtrace:

File: /var/www/project.test/public/application/third_party/MX/Router.php
Line: 239
Function: strpos

File: /var/www/project.test/public/application/third_party/MX/Router.php
Line: 101
Function: _set_default_controller

File: /var/www/project.test/public/index.php
Line: 324
Function: require_once
Run Code Online (Sandbox Code Playgroud)

小智 8

我像这样更改函数 set_class 上的代码行:

    {
        //this is the original codes I commented
    /* $suffix = $this->config->item('controller_suffix');
        if (strpos($class, $suffix) === FALSE)
        {
            $class .= $suffix;
        }
        parent::set_class($class); 
    */

      //and change with this one
        $suffix = (string) $this->config->item('controller_suffix');
        if ($suffix && strpos($class, $suffix) === FALSE) {
            $class .= $suffix;
        }

        parent::set_class($class);
    }

Source: https://forum.codeigniter.com/thread-72393.html
Run Code Online (Sandbox Code Playgroud)


Cha*_*rma 6

只需更新 Router.php 文件路径中的函数:application\third_party\MX\Router.php

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

    $suffix = (string) $this->config->item('controller_suffix');
    if ($suffix && strpos($class, $suffix) === FALSE)
    {
        $class .= $suffix;
    }
    parent::set_class($class);
}
Run Code Online (Sandbox Code Playgroud)

在此之后它工作正常!