Codeigniter constructors. What is the difference?

后端 未结 4 1136
轻奢々
轻奢々 2021-02-09 18:03

I see two types of contructors in CI. For instance...

class Blog extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
    }
}
         


        
4条回答
  •  醉梦人生
    2021-02-09 18:31

    If you are using Codeigniter 2+ (which you should be)... The second option will not work, as it uses the PHP4 style constructor calls.

    Actually, the second option wouldn't work anyway because the php4 constructor call needs to match the class you're extending...

    So yeah, use the first one. It uses PHP5 style constructor calls.

    For more information on PHP5 constructors

提交回复
热议问题