PHP 4 style constructors (methods that have the same name as the class they are defined in) are deprecated, and will be removed in the future. PHP 7 will emit E_DEPRECATED if a PHP 4 constructor is the only constructor defined within a class. Classes that implement a __construct()method are unaffected.
// Methods with the same name as their class will not be constructors in a future version of PHP
class FooBar {
var $test = 42;
function set() {}
function FooBar() {
// NOP
}
}
will be reported as follows:
* oldClassConstructors
* Line 129: ` function FooBar() {`
and PHP7 will complain:
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP
PHP 4 style constructors:
will be reported as follows:
and PHP7 will complain:
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP