PHP 4 風格的建構子(與其定義所在的類別名稱相同的方法)已被棄用,並將在未來移除。如果 PHP 4 建構子是類別中唯一定義的建構子,PHP 7 將發出 E_DEPRECATED
錯誤。實作了 __construct() 方法的類別不受影響。
<?php
class foo {
function foo() {
echo '我是建構子';
}
}
?>
以上範例將輸出
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
對未宣告為 static 的方法進行靜態呼叫已被棄用,並可能在未來移除。
<?php
class foo {
function bar() {
echo 'I am not static!';
}
}
foo::bar();
?>
以上範例將輸出
Deprecated: Non-static method foo::bar() should not be called statically in - on line 8 I am not static!
password_hash() 函式的 salt 選項已被棄用,以防止開發人員產生他們自己的(通常不安全的)salt。當開發人員未提供 salt 時,該函式本身會產生一個加密安全的 salt - 因此應該不需要自訂 salt 生成。
capture_session_meta
SSL 內容選項capture_session_meta
SSL 內容選項已被棄用。現在可以透過 stream_get_meta_data() 函式取得 SSL 中繼資料。