核心:
- PHP4風格的建構子將會被棄用。 (和類別名稱同名的方法視為建構方法,這是PHP4的語法。)
- 靜態呼叫非靜態方法將被棄用。
OpenSSL
capture_session_meta選項將被棄用,可以呼叫stream_get_meta_data()來取得。
PHP4 風格的建構子
#在PHP4 中類別的函數可以與類別名稱同名,這一特性在PHP7中被廢棄,同時會發出一個E_DEPRECATED 錯誤。當方法名稱與類別名稱相同,且類別不在命名空間中,同時PHP5的建構子(__construct)不存在時,會產生一個 E_DEPRECATED 錯誤。
實例
<?php
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();
?>以上程式執行輸出結果為:Deprecated: Non-static method A::b() should not be called statically in...Non-static call












![PHP實戰開發極速入門: PHP快速創建[小型商業論壇]](https://img.php.cn/upload/course/000/000/035/5d27fb58823dc974.jpg)









