PHP4 風(fēng)格的構造函數(方法名和類(lèi)名一樣)將被棄用,并在將來(lái)移除。
如果在類(lèi)中僅使用了 PHP4 風(fēng)格的構造函數,PHP7 會(huì )產(chǎn)生 E_DEPRECATED
警告。
如果還定義了 __construct() 方法則不受影響。
<?php
class foo {
function foo() {
echo 'I am the constructor';
}
}
?>
以上例程會(huì )輸出:
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; foo has a deprecated constructor in example.php on line 3
廢棄了 靜態(tài)(Static) 調用未聲明成 static 的方法,未來(lái)可能會(huì )徹底移除該功能。
<?php
class foo {
function bar() {
echo 'I am not static!';
}
}
foo::bar();
?>
以上例程會(huì )輸出:
Deprecated: Non-static method foo::bar() should not be called statically in - on line 8 I am not static!
廢棄了 password_hash() 函數中的鹽值選項,阻止開(kāi)發(fā)者生成自己的鹽值(通常更不安全)。 開(kāi)發(fā)者不傳該值時(shí),該函數自己會(huì )生成密碼學(xué)安全的鹽值。因此再無(wú)必要傳入自己自定義的鹽值。
capture_session_meta
SSL 上下文選項
廢棄了 capture_session_meta
內的 SSL 上下文選項。
現在可以通過(guò) stream_get_meta_data() 獲取 SSL 元數據(metadata)。