Home >Backend Development >PHP Tutorial >PHP7 deprecated features
PHP4-style constructors, which have the same name as the class because they are methods of the class in which they are defined, are now deprecated, and will be removed in the future. If PHP4's constructor is just a constructor defined in a class, PHP7 will issue E_DEPRECATED. Class implementation constructor __construct() method is not affected.
<?php class A { function A() { print('Style Constructor'); } } ?>
This will produce the following output in the browser -
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; A has a deprecated constructor in...
<?php class A { function b() { print('Non-static call'); } } A::b(); ?>
This will produce the following output in the browser -
Deprecated: Non-static method A::b() should not be called statically in... Non-static call
The salt option of the password_hash() function has been Deprecated so developers don't generate their own (usually unsafe) salts. The function itself generates a cryptographically secure salt when the developer does not provide a salt value - therefore, custom salt generation is no longer needed.