The history of PHP says that the older versions of PHP use the class name as a method for a constructor for the same class.
The PHP 5.3.3 documentation says that:
Methods with the same name as the last element of a namespaced class name will no longer be treated as constructor. This change doesn't affect non-namespaced classes.
Example:
namespace A;
class classOne{
public function methodOne(){}
public function methodTwo(){}
public function classOne(){} //Constructor
}
class classTwo{
public function methodOne(){}
public function methodTwo(){}
public function classTwo(){} //Constructor
}
So according to this documentation, classOne()
and classTwo()
are not considered as constructors? What is the reasoning behind this? Can anyone tell me?