-- Kexiao Liao <liaok ccf.org> wrote
(on Friday, 24 August 2007, 04:25 AM -0700):
> There is a method, init() of Zend Class. When will it
be called? Doese it
> belong to Zend Framework only or it belong to Php5.2
OO?
There is no 'Zend' class in current distributions of ZF.
That said, several ZF classes have an init() method that
they call from
the constructor. The reason behind this is that some of the
abstract
classes have very specific constructor signatures, and to
simplify
extending them they call an init() method at the end where
developers
may add additional initialization functionality.
As an example, here's the constructor signature for
Zend_Controller_Action:
public function __construct(
Zend_Controller_Request_Abstract $request,
Zend_Controller_Response_Abstract $response,
array $invokeVars = array())
Who would want to write that every time they wanted to add
initialization-time logic for their controllers?
So, init() isn't a PHP method, but is instead a convenience
method we've
added to a number of ZF classes. In all cases I know of,
it's called as
the last action in the constructor, so it's effectively an
instantiation
method.
--
Matthew Weier O'Phinney
PHP Developer | matthew zend.com
Zend - The PHP Company | http://www.zend.com/
|