when to use parent::__construct(); in the class?

Dear all
I`ve started learning CI by the tutorial in the User Guide.
I found the News_model did not add the parent::__construct()
News_model extends CI_Model {
public function __construct()
But the News controller starts with parent::__construct()
class News extends CI_Controller {

public function __construct()
Could anyone kindly tell me the differences?
And whats the criteria of adding the parent::__construct() when creating the class?
Many thanks

You only need to add parent::__construct(), if you are doing something in your __construct().

just having
public function __construct()

with nothing else doesn't do anything.

See: http://ellislab.com/codeigniter/user-gui...nstructors

[eluser]Bart v B[/eluser]
In other words, if you are planning to do things only in that object, then you can reference that in your constructor.

to inherit directly the attributes of the parent class. Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.