Codeigniter 3 HMVC已经崩溃了。

5

在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
5个回答

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

8
只需在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);
}

之后它运行正常!


3

1
这个链接已经失效。 - demenvil

1
将其更改为:
if (strpos($class, chr($suffix)) === FALSE)

0

这个链接无法使用。它显示“存储库未找到”。


你的回答可以通过提供更多支持信息来改进。请编辑以添加进一步的细节,例如引用或文档,以便他人可以确认你的答案是正确的。您可以在帮助中心中找到有关如何编写良好答案的更多信息。 - Community
这并没有回答问题。一旦您拥有足够的声望,您将能够评论任何帖子;相反,提供不需要询问者澄清的答案。- 来自审核 - Abdullah Mujahid

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接