开发者

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

开发者 https://www.devze.com 2023-01-17 05:40 出处:网络
I wa开发者_开发技巧s wondering what is the difference between __construct() and init() functions in a PHP application, more particularly in a Zend Framework application.init() is called by the constru

I wa开发者_开发技巧s wondering what is the difference between __construct() and init() functions in a PHP application, more particularly in a Zend Framework application.


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 :

  • Zend Framework: What are the differences between init() and preDispatch() functions in controller objects?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消