在 PHP 7 中,已經(jīng)不再支持某些功能,并且這些功能將會被刪除。下文介紹了這些在 PHP 7 不再支持的功能:
PHP 4 風(fēng)格的構(gòu)造函數(shù)是與它們定義的類名相同的方法,現(xiàn)在已被棄用,將來會被刪除。如果 PHP 4 構(gòu)造函數(shù)是類中定義的唯一構(gòu)造函數(shù),PHP7 將會發(fā)出 E_DEPRECATED。實(shí)現(xiàn) __construct()方法的類不受影響。
<?php
class A {
function A() {
print('Style Constructor');
}
}
?>
它產(chǎn)生以下瀏覽器輸出:
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)方法的靜態(tài)調(diào)用已棄用,將來可能會被刪除。
<?php
class A {
function b() {
print('Non-static call');
}
}
A::b();
?>
它產(chǎn)生以下瀏覽器輸出:
Deprecated: Non-static method A::b() should not be called statically in...
Non-static call
password_hash()函數(shù)的 salt 選項已被棄用,因此開發(fā)人員不會生成自己的(通常不安全的)鹽。該功能本身產(chǎn)生一種加密安全的鹽,當(dāng)開發(fā)商沒有提供鹽時,因此不再需要定制的鹽生成。
該 capture_session_meta SSL 上下文選項已被棄用。現(xiàn)在,通過 stream_get_meta_data()函數(shù)使用 SSL 元數(shù)據(jù)。
被移除的函數(shù)列表如下:
更多建議: