PHP currently supports two naming conventions for constructors. PHP 4 supports Java-style constructors:
class A { public function A() { echo "I'm a constructor for class A!"; } }
PHP 5 supports both Java-style constructors and the magic method syntax:
class A { public function __construct() { echo "I'm a constructor for class A!"; } }
The Java-style syntax is deprecated, and some of its functions do not work in the latest PHP . However, this has an interesting property, which I do not know an analogue for the syntax of the "magic method". If the foobar derived class does not have an explicit constructor, then the foobar method of the base class becomes the foobar constructor:
class A { public function A() { echo "I'm a constructor for class A!"; } public function B() { echo "I'm a constructor for class B!"; } } class B extends A { }
Since Java style constructors are becoming obsolete, what will happen to the set-the-constructor-in-parent language function?
source share