Welcome Guest, Not a member yet? Register   Sign In
constructor - why, where, when??
#8

[eluser]Unknown[/eluser]
Hi, as I walked through the user guide, I see only a few lines to describe the constructor named in the PHP5 manner. In fact, most examples still using the PHP4 implementation (i.e. having a function name same as the class name.)

For newcomers and new developers using PHP5, the constructor is supposed to be

__construct()

also the user guide didn't mention enough to use the PHP5's style of essential call to the inherited class's constructor using,

parent::__construct()

I hope my observation is reasonable and could be considered as a need to make an immediate supplementary note to the user guide.

As the previous replies stated, the __construct in PHP5 is the preferred practice. Please help CI developer to have a more concrete and clear in this issue.

I personally think the constructor and destructor are both critical for any Object-Oriented design/implementation. The naming and implementation difference between PHP4 and PHP5 had been a long discussion. The rationale using __construct instead of the same function name as class name was welcomed by many developers.

Hope we share our views. :-)


Messages In This Thread
constructor - why, where, when?? - by El Forum - 02-14-2009, 05:27 PM
constructor - why, where, when?? - by El Forum - 02-14-2009, 06:13 PM
constructor - why, where, when?? - by El Forum - 02-14-2009, 06:13 PM
constructor - why, where, when?? - by El Forum - 02-14-2009, 06:14 PM
constructor - why, where, when?? - by El Forum - 02-14-2009, 06:36 PM
constructor - why, where, when?? - by El Forum - 02-14-2009, 06:40 PM
constructor - why, where, when?? - by El Forum - 02-14-2009, 07:25 PM
constructor - why, where, when?? - by El Forum - 03-01-2009, 10:05 AM
constructor - why, where, when?? - by El Forum - 03-01-2009, 10:34 AM
constructor - why, where, when?? - by El Forum - 03-01-2009, 10:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB