Deprecated Features in PHP 7

PHP 7 新特性New Features in PHP 7


PHP4-style constructors

In PHP 4, functions in a class could have the same name as the class. This feature is deprecated in PHP 7, and an E_DEPRECATED error is issued. When a method name is the same as the class name, the class is not in a namespace, and the PHP 5 constructor (__construct) does not exist, an E_DEPRECATED error is generated.

Example

Example

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

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

Calling non-static methods statically

Calling non-static methods statically is no longer supported:

Example

Example

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

The output of the above program is:

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

password_hash() random factor option

The original salt value of the function no longer needs to be provided by the developer. The function has built-in salt capability by default, so there is no need for the developer to provide a salt value.


capture_session_meta SSL context option

The "capture_session_meta" SSL context option has been deprecated. Encryption-related metadata active on stream resources can be accessed via the return value of stream_get_meta_data().


PHP 7 新特性New Features in PHP 7

Other extensions