PHP 7 廢棄特性

PHP 7 新特性 PHP 7 新特性


PHP4 風(fēng)格的構(gòu)造函數(shù)

在 PHP4 中類中的函數(shù)可以與類名同名,這一特性在 PHP7 中被廢棄,同時會發(fā)出一個 E_DEPRECATED 錯誤。當(dāng)方法名與類名相同,且類不在命名空間中,同時PHP5的構(gòu)造函數(shù)(__construct)不存在時,會產(chǎn)生一個 E_DEPRECATED 錯誤。

實例

實例

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

以上程序執(zhí)行輸出結(jié)果為:

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

以靜態(tài)的方式調(diào)用非靜態(tài)方法

以靜態(tài)的方式調(diào)用非靜態(tài)方法,不再支持:

實例

實例

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

以上程序執(zhí)行輸出結(jié)果為:

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

password_hash() 隨機(jī)因子選項

函數(shù)原 salt 量不再需要由開發(fā)者提供了。函數(shù)內(nèi)部默認(rèn)帶有 salt 能力,無需開發(fā)者提供 salt 值。


capture_session_meta SSL 上下文選項

廢棄了 "capture_session_meta" SSL 上下文選項。 在流資源上活動的加密相關(guān)的元數(shù)據(jù)可以通過 stream_get_meta_data() 的返回值訪問。


PHP 7 新特性 PHP 7 新特性