views:

99

answers:

2

Hi All,

I was wondering what is the difference between __construct() and init() functions in a PHP application, more particularly in a Zend Framework application.

+2  A: 

__construct is a php magic method. It always exists and is called on object creation. init() is just a reguar method usually used in ZF..

kgb
+10  A: 

init() is called by the constructor.

init() isn't defined in the specification of PHP, it's only a method available with the Zend Framework to help initialize without having to rewrite the constructor yourself.


Resources : - zend framework init() method

On the same topic :

Colin Hebert
+1 and congrats on crossing 10K :)
Amarghosh