tom
tom

Reputation: 8359

What's the difference between __construct() and init()

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

Upvotes: 42

Views: 46034

Answers (2)

Colin Hebert
Colin Hebert

Reputation: 93157

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.


On the same topic :

Upvotes: 60

Sergey Eremin
Sergey Eremin

Reputation: 11080

__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..

Upvotes: 12

Related Questions