PHP4 風(fēng)格的構(gòu)造函數(shù)(方法名和類名一樣)將被棄用,并在將來(lái)移除。
如果在類中僅使用了 PHP4 風(fēng)格的構(gòu)造函數(shù),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) 調(diào)用未聲明成 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() 函數(shù)中的鹽值選項(xiàng),阻止開發(fā)者生成自己的鹽值(通常更不安全)。 開發(fā)者不傳該值時(shí),該函數(shù)自己會(huì)生成密碼學(xué)安全的鹽值。因此再無(wú)必要傳入自己自定義的鹽值。
capture_session_meta
SSL 上下文選項(xiàng)
廢棄了 capture_session_meta
內(nèi)的 SSL 上下文選項(xiàng)。
現(xiàn)在可以通過(guò) stream_get_meta_data() 獲取 SSL 元數(shù)據(jù)(metadata)。