Home  >  Article  >  Backend Development  >  PHP's CI framework keeps looping endlessly. What's the reason?

PHP's CI framework keeps looping endlessly. What's the reason?

WBOY
WBOYOriginal
2016-08-04 09:19:001106browse

application/controllers/sponsor.php

<code>class Sponsor extends CI_Controller{

    public function index($page = 'home'){
        $this->load->library('base');//如果使用 $this->load->libraries('base'); 必死循环
        $this->base->pageLogin();
        print_r(8888);
    }
}
</code>

application/libraries/Base.php

<code>class Base{

    public function __construct(){
        $this->CI =& get_instance();
    }

    public function pageLogin($must=false){
        var_dump($this->CI->session);//如果使用 $this->session 必死循环
    }
}

</code>

The above two places are fatal loops.


I heard that the CI framework is quite easy to use. I have an urgent project these days. I used CI for a day and I cried. I didn’t even write the WeChat login. If I write a wrong step, it will lead to an endless loop. Can you report the error to me? Brother TAT.

Reply content:

application/controllers/sponsor.php

<code>class Sponsor extends CI_Controller{

    public function index($page = 'home'){
        $this->load->library('base');//如果使用 $this->load->libraries('base'); 必死循环
        $this->base->pageLogin();
        print_r(8888);
    }
}
</code>

application/libraries/Base.php

<code>class Base{

    public function __construct(){
        $this->CI =& get_instance();
    }

    public function pageLogin($must=false){
        var_dump($this->CI->session);//如果使用 $this->session 必死循环
    }
}

</code>

The above two places are fatal loops.


I heard that the CI framework is quite easy to use. I have an urgent project these days. I used CI for a day and I cried. I didn’t even write the WeChat login. If I write a wrong step, it will lead to an endless loop. Can you report the error to me? Brother TAT.

It shouldn’t be at the controller

function __construct(){

<code>   parent::__construct()</code>

Then introduce librari’s

here?

<code>$this->load->library('Base');</code>

When loading a class library, the name must correspond to the class library name!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn