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

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

WBOY
Release: 2016-08-04 09:19:00
Original
1163 people have browsed it

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login

Then introduce librari’s

here?

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

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template