Codeigniter php
frameworks, we will continue the next part or the last part of controllers,
now is part number 7, didn’t read the part 6, please read these part first. In the
part 7 we will learn about class constructors,
if you intend to use a constructor in any of your controllers, you must place
the following line of code like this parent::__construct();
.The reason this line is necessary is because your local constructor
will be overriding the one in the parent controller class so we need to
manually call it.
<?php
class Blog extends CI_Controller {
public function __construct() {
parent::__construct();
// Your own constructor code
}
}
?>
Constructors are useful if you need to set some default
values, or run a default process when your class is instantiated. Codeigniter php frameworks. Constructors
can return a value, but they can do some default work.
I have something for you to inform about reserved function names. Since your controller
classes will extend the main application controller you must be careful not to
name your functions identically to the ones used by that class, otherwise your
local functions will override them. See Reserved Names at codeigniter user guide for a full list. Ok, I think
this is the end of our learning about controllers, please stay at Codeigniter
php frameworks.
This post of Codeigniter php frameworks: controllers part 7
is references from http://codeigniter.com/user_guide/general/controllers.html.
Comments
Post a Comment