Thursday, May 12, 2011

Constructor in Class

more info.. http://evergreenphp.blogspot.com


Constructor

void__cons tru ct ([mixed$args [,$... ]] )
PHP 5 allows developers to declare constructor methods for classes. Classes which have a constructor
method call this method on each newly-created object, so it is suitable for any initialization that the
object may need before it is used.
Note: Parent constructors are not called implicitly if the child class defines a constructor. In
order to run a parent constructor, a call top aren t::__con s tru ct() within the child
constructor is required.

For backwards compatibility, if PHP 5 cannot find a__cons tru ct() function for a given class, it will
search for the old-style constructor function, by the name of the class. Effectively, it means that the
only case that would have compatibility issues is if the class had a method named__cons truct() which
was used for different semantics.

No comments: