PHP 7 廢棄特性
PHP4 風格的構造函數
在 PHP4 中類中的函數可以與類名同名,這一特性在 PHP7 中被廢棄,同時會發出一個 E_DEPRECATED 錯誤。當方法名與類名相同,且類不在命名空間中,同時PHP5的構造函數(__construct)不存在時,會產生一個 E_DEPRECATED 錯誤。
實例
實例
<?php
class A {
function A() {
print('Style Constructor');
}
}
?>
class A {
function A() {
print('Style Constructor');
}
}
?>
以上程式執行輸出結果為:
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();
?>
class A {
function b() {
print('Non-static call');
}
}
A::b();
?>
以上程式執行輸出結果為:
Deprecated: Non-static method A::b() should not be called statically in... Non-static call
password_hash() 隨機因數選項
函數原 salt 量不再需要由開發者提供了。函數內部默認帶有 salt 能力,無需開發者提供 salt 值。
capture_session_meta SSL 上下文選項
廢棄了 "capture_session_meta" SSL 上下文選項。 在流資源上活動的加密相關的元數據可以通過 stream_get_meta_data() 的返回值訪問。