Currently, PHP supports two naming conventions for constructors. PHP 4 supported Java-style constructors:
class A
{
public function A()
{
echo "I'm a constructor for class A!";
}
}
PHP 5 supports both the Java-style constructors and a “magic method” syntax:
class A
{
public function __construct()
{
echo "I'm a constructor for class A!";
}
}
The Java-style syntax is slated for deprecation, and some features of it don’t work in the latest PHP. However, it has an interesting property that I know of no analogue for with the “magic method” syntax. If derived class foobar has no 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 being deprecated, what will become of the set-the-constructor-in-the-parent language feature?
You probably learned this here, for PHP 4.
As you already know, in PHP 5 documentation (here) it is stated that if no __construct() is used or inherited, the old syntax kicks in as a fallback:
So the old syntax should still be valid, as PHP 5.4.11. There is no explicit plan for deprecation, right now, even if it’s foreseeable.
Anyway, when (and if) they will be dropped, this feature will be dropped too as there is no way to reproduce it with the __construct() syntax.