• <small id='XRpg6'></small><noframes id='XRpg6'>

        • <bdo id='XRpg6'></bdo><ul id='XRpg6'></ul>
        <legend id='XRpg6'><style id='XRpg6'><dir id='XRpg6'><q id='XRpg6'></q></dir></style></legend>
        <tfoot id='XRpg6'></tfoot>
        <i id='XRpg6'><tr id='XRpg6'><dt id='XRpg6'><q id='XRpg6'><span id='XRpg6'><b id='XRpg6'><form id='XRpg6'><ins id='XRpg6'></ins><ul id='XRpg6'></ul><sub id='XRpg6'></sub></form><legend id='XRpg6'></legend><bdo id='XRpg6'><pre id='XRpg6'><center id='XRpg6'></center></pre></bdo></b><th id='XRpg6'></th></span></q></dt></tr></i><div id='XRpg6'><tfoot id='XRpg6'></tfoot><dl id='XRpg6'><fieldset id='XRpg6'></fieldset></dl></div>
      1. 找不到代码点火器 MY_Controller

        时间:2023-10-12

            <bdo id='k0fU8'></bdo><ul id='k0fU8'></ul>

            <i id='k0fU8'><tr id='k0fU8'><dt id='k0fU8'><q id='k0fU8'><span id='k0fU8'><b id='k0fU8'><form id='k0fU8'><ins id='k0fU8'></ins><ul id='k0fU8'></ul><sub id='k0fU8'></sub></form><legend id='k0fU8'></legend><bdo id='k0fU8'><pre id='k0fU8'><center id='k0fU8'></center></pre></bdo></b><th id='k0fU8'></th></span></q></dt></tr></i><div id='k0fU8'><tfoot id='k0fU8'></tfoot><dl id='k0fU8'><fieldset id='k0fU8'></fieldset></dl></div>
              <tfoot id='k0fU8'></tfoot>
            • <small id='k0fU8'></small><noframes id='k0fU8'>

                <tbody id='k0fU8'></tbody>
                <legend id='k0fU8'><style id='k0fU8'><dir id='k0fU8'><q id='k0fU8'></q></dir></style></legend>

                  本文介绍了找不到代码点火器 MY_Controller的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在网站上使用 Codeigniter.2.1.3,所以我需要扩展 CI_Controller 以便我可以添加一个要与所有控制器一起执行的方法,所以我做了 user_guide 中的内容:

                  i’m using the Codeigniter.2.1.3 for a website, so i need to extend the CI_Controller so i can add a method to be executed with all controllers so i did what’s in the user_guide:

                  在 application/core 文件夹中创建一个名为 MY_Controller.php 的文件,在其中创建扩展 CI_Controller 的 MY_Controller 类,更改我的常规控制器以扩展 MY_controller,如下所示:MY_controller.php:

                  creating a file named MY_Controller.php in the application/core folder the creating in it MY_Controller Class that extends the CI_Controller, the changing my regular controller to extend the MY_controller like this: MY_controller.php:

                  class MY_Controller extends CI_Controller{
                      protected $page;
                      # Constructor
                      function __construct (){
                          parent::__construct();
                          #code shared with all controllers
                      }
                      public function get_page(){
                          #code to get_the right page here
                      }
                  }
                  

                  名为 Regular.php 的常规控制器:

                  regular controller named Regular.php:

                  class Regular extends MY_Controller{
                       public function __construct(){
                           parent::__construct();
                       }
                       public function index(){
                            $this->get_page();
                       }
                  }
                  

                  但不断出现以下错误:

                  致命错误:在第 2 行的/var/www/immo/CodeIgniter_2.1.3/application/controllers/regular.php 中找不到MY_Controller"类

                  Fatal error: Class ‘MY_Controller’ not found in /var/www/immo/CodeIgniter_2.1.3/application/controllers/regular.php on line 2

                  推荐答案

                  您需要包含您的 MY_Controller 类或自动加载它.我建议您通过将以下内容添加到您的 application/config/config.php 文件来自动加载它.

                  You would need to include your MY_Controller class or auto-load it. I suggest you auto-load it by adding the following to your application/config/config.php file.

                  function __autoload($class)
                  {
                      if (strpos($class, 'CI_') !== 0)
                      {
                          if (file_exists($file = APPPATH . 'core/' . $class . EXT))
                          {
                              include $file;
                          }
                      }
                  } 
                  

                  这篇关于找不到代码点火器 MY_Controller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:检查是否在“开发"中带 Symfony 的控制器内的模式 下一篇:用户友好的 URL - mod 重写和 php 重定向

                  相关文章

                  <i id='CqGs0'><tr id='CqGs0'><dt id='CqGs0'><q id='CqGs0'><span id='CqGs0'><b id='CqGs0'><form id='CqGs0'><ins id='CqGs0'></ins><ul id='CqGs0'></ul><sub id='CqGs0'></sub></form><legend id='CqGs0'></legend><bdo id='CqGs0'><pre id='CqGs0'><center id='CqGs0'></center></pre></bdo></b><th id='CqGs0'></th></span></q></dt></tr></i><div id='CqGs0'><tfoot id='CqGs0'></tfoot><dl id='CqGs0'><fieldset id='CqGs0'></fieldset></dl></div>
                1. <small id='CqGs0'></small><noframes id='CqGs0'>

                    <bdo id='CqGs0'></bdo><ul id='CqGs0'></ul>

                      <tfoot id='CqGs0'></tfoot>

                      <legend id='CqGs0'><style id='CqGs0'><dir id='CqGs0'><q id='CqGs0'></q></dir></style></legend>