Php 如何在codeigniter中创建自定义错误视图

Php 如何在codeigniter中创建自定义错误视图,php,codeigniter,Php,Codeigniter,我对此也有同样的问题 我尝试了来自的解决方案,因为这是最符合逻辑的答案,但问题是他建议的类无法加载,因此它被Codeigniter的默认错误所卡住 我想创建一个自定义错误视图,因此我试图直接更改文件system/core/URI.php,但它无法使用重定向功能,因为: autoload['helper']=“url” 任何人都知道如何解决这个问题吗?在system/core/Input.php上进行更改,试试这个,这个必须工作。如果不工作,请告诉我,这个对我有效 <?php

我对此也有同样的问题

我尝试了来自的解决方案,因为这是最符合逻辑的答案,但问题是他建议的类无法加载,因此它被Codeigniter的
默认错误所卡住

我想创建一个
自定义错误视图
,因此我试图直接更改文件
system/core/URI.php
,但它无法使用重定向功能,因为:

autoload['helper']=“url”


任何人都知道如何解决这个问题吗?

在system/core/Input.php上进行更改,试试这个,这个必须工作。如果不工作,请告诉我,这个对我有效

    <?php

   class MY_Input extends CI_Input {

    /**
     * Clean Keys
     *
     * This is a helper function. To prevent malicious users
     * from trying to exploit keys we make sure that keys are
     * only named with alpha-numeric text and a few other items.
     * 
     * Extended to allow: 
     *      - '.' (dot), 
     *      - '[' (open bracket),
     *      - ']' (close bracket)
     * 
     * @access  private
     * @param   string
     * @return  string
     */
    function _clean_input_keys($str) {
        if (!preg_match("/^[a-z0-9:_\/\.\[\]-]+$/i", $str)) {
            /**
             * Check for Development enviroment - Non-descriptive 
             * error so show me the string that caused the problem 
             */
            if (getenv('ENVIRONMENT') && getenv('ENVIRONMENT') == 'DEVELOPMENT')
                var_dump($str);
            exit('Disallowed Key Characters.');
        }

        // Clean UTF-8 if supported
        if (UTF8_ENABLED === TRUE) {
            $str = $this->uni->clean_string($str);
        }

        return $str;
    }

}

// /?/> /* Should never close php file - if you have a space after can mess your life up */

在system/core/Input.php上进行更改,试试这个,这个必须工作,如果不工作,请告诉我,这个适合我

    <?php

   class MY_Input extends CI_Input {

    /**
     * Clean Keys
     *
     * This is a helper function. To prevent malicious users
     * from trying to exploit keys we make sure that keys are
     * only named with alpha-numeric text and a few other items.
     * 
     * Extended to allow: 
     *      - '.' (dot), 
     *      - '[' (open bracket),
     *      - ']' (close bracket)
     * 
     * @access  private
     * @param   string
     * @return  string
     */
    function _clean_input_keys($str) {
        if (!preg_match("/^[a-z0-9:_\/\.\[\]-]+$/i", $str)) {
            /**
             * Check for Development enviroment - Non-descriptive 
             * error so show me the string that caused the problem 
             */
            if (getenv('ENVIRONMENT') && getenv('ENVIRONMENT') == 'DEVELOPMENT')
                var_dump($str);
            exit('Disallowed Key Characters.');
        }

        // Clean UTF-8 if supported
        if (UTF8_ENABLED === TRUE) {
            $str = $this->uni->clean_string($str);
        }

        return $str;
    }

}

// /?/> /* Should never close php file - if you have a space after can mess your life up */

我试图将此错误重定向到自定义页面。我想如果我这样做了,我就不能使用重定向,因为在这个文件中,我可能无法加载url帮助程序。这就是为什么你要加载url帮助程序的核心文件。你可以将它加载到你视图的控制器中。我想为这个错误创建一个自定义页面。。。但我想我不能?只需调用错误_404或创建这种类型的单独视图页面我有用于此错误的自定义视图页面,但无法加载它?我尝试将此错误重定向到自定义页面。我想如果我这样做了,我就不能使用重定向,因为在这个文件中,我可能无法加载url帮助程序。这就是为什么你要加载url帮助程序的核心文件。你可以将它加载到你视图的控制器中。我想为这个错误创建一个自定义页面。。。但是我想我不能?只需调用error_404或创建这种类型的单独查看页面我有用于此错误的自定义查看页面,但我无法加载它?