PHP7 deprecated features


Core:

  • PHP4 style constructors will be deprecated. (Methods with the same name as the class name are considered constructors, which is the syntax of PHP4.)
  • Static calls to non-static methods will be deprecated.

OpenSSL

The capture_session_meta option will be deprecated and can be obtained by calling stream_get_meta_data().


PHP4 style constructor

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

Example

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

The above program execution output result 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...

## Calling non-static methods in a static way

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

Instance

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

The above program execution output result is:

Deprecated: Non-static method A::b() should not be called statically in...Non-static call


password_hash() random factor option

function The original salt amount 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().