Need help about php framework (codeigniter)

╄→гoц情女王★ 提交于 2019-12-25 05:10:05

问题


I know php well. But I am a very new learner of php framework . I am learning codeigniter 2.0.3. I am trying to develop a simple hello world application.

I have tried this code..

class Hello extends Controller{
  function Hello(){
    parent::Controller();
  }
  function you(){
    $this->load->view("you_view");
  }

}

But unfortunately I am receiving this error ...

Fatal error: Class 'Controller' not found in C:\wamp\www\CodeIgniter\application\controllers\hello_world.php on line 7


回答1:


Should be:

class Hello extends CI_Controller{
  function __construct() {
    parent::__construct();
            /* use this only for setting default values, 
            loading helpers, models, ... */
    }
    function you() {
      $this->load->view("you_view");
    }
 }



回答2:


Controller should be CI_Controller, like this:

class Hello extends CI_Controller{



回答3:


CI_Controller not Controller on

class Hello extends Controller{

becomes

class Hello extends CI_Controller{




回答4:


Here more information , examples and user Guide. Check this

Change Controller to CI_Controller in your code



来源:https://stackoverflow.com/questions/9946565/need-help-about-php-framework-codeigniter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!