PHP 7 obsolete feature


PHP4 style constructor

In PHP4, the function in the class can have the same name as the class name. This feature is Deprecated in PHP7 and will issue an E_DEPRECATED error. When the method name is the same as the class name, the class is not in the namespace, and the PHP5 constructor (__construct) does not exist, an E_DEPRECATED error will be generated.

Example

Example

<?php
class A {
   function A() {
      print('Style Constructor');
   }
}
?>

The execution output of the above program is:

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...

##Call non-static methods in a static way

With Calling non-static methods in a static way is no longer supported:

Instance

Instance

<?php
class A {
   function b() {
      print('Non-static call');
   }
}
A::b();
?>

The output result of the above program execution is:

Deprecated: Non-static method A::b() should not be called statically in...
Non-static call
##password_hash() random factor Options

The original salt quantity of the function no longer needs to be provided by the developer. The function has salt capability by default, and developers do not need to provide a salt value.

capture_session_meta SSL context option

The "capture_session_meta" SSL context option is deprecated. Encryption-related metadata active on the stream resource can be accessed through the return value of stream_get_meta_data().


Next Section