PHP7棄用了哪些功能

2020-12-26 09:09 更新

在 PHP 7 中,已經(jīng)不再支持某些功能,并且這些功能將會被刪除。下文介紹了這些在 PHP 7 不再支持的功能:

PHP 7 棄用了 PHP 4 風(fēng)格的構(gòu)造函數(shù)

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...

PHP7 棄用了靜態(tài)調(diào)用非靜態(tài)方法

對非靜態(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()salt 選項被棄用

password_hash()函數(shù)的 salt 選項已被棄用,因此開發(fā)人員不會生成自己的(通常不安全的)鹽。該功能本身產(chǎn)生一種加密安全的鹽,當(dāng)開發(fā)商沒有提供鹽時,因此不再需要定制的鹽生成。

capture_session_meta SSL 上下文選項被棄用

該 capture_session_meta SSL 上下文選項已被棄用。現(xiàn)在,通過 stream_get_meta_data()函數(shù)使用 SSL 元數(shù)據(jù)。

在 PHP7 中移除的函數(shù)列表

被移除的函數(shù)列表如下: 

  • 已廢棄的 mcrypt_generic_end() 函數(shù)已被移除,您可以使用 mcrypt_generic_deinit() 代替。 
  • 已廢棄的 mcrypt_ecb(), mcrypt_cbc()、 mcrypt_cfb() 和 mcrypt_ofb() 函數(shù)已被移除。 
  • set_magic_quotes_runtime() (別名:magic_quotes_runtime() )已被移除;它們在 PHP5.3.0 中已經(jīng)被廢棄,并且在 PHP5.4.0 也由于魔術(shù)引號的廢棄而失去功能。 
  • 已廢棄的 set_socket_blocking() 函數(shù)已被移除,您可以使用 stream_set_blocking() 代替。 
  • 在 PHP-FPM 不再使用 dl(),在 CLI 和 embed SAPIs 中仍可用。 
  • GD 庫中下列函數(shù)被移除:imagepsbbox()、imagepsencodefont()、imagepsextendfont()、imagepsfreefont()、imagepsloadfont()、imagepsslantfont()、imagepstext() 
  • 在配置文件 php.ini 中,always_populate_raw_post_data、asp_tags、xsl.security_prefs 被移除了。

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號