向后不兼容

雖然大部分 PHP 5 的代碼無需修改即可正常運行, 但是有部分代碼是無法向后兼容的:

使用數(shù)組標(biāo)識符為類定義數(shù)組類型的屬性時,數(shù)組的鍵不會被覆蓋

在 PHP 5.6 之前的版本中,為類定義數(shù)組類型的屬性時, 如果數(shù)組中同時使用了顯式數(shù)組鍵和隱式數(shù)組鍵,并且顯式的鍵和隱式的序列鍵相同, 那么數(shù)組的鍵將被覆蓋。例如:

<?php
class {
    const 
ONE 1;
    public 
$array = [
        
self::ONE => 'foo',
        
'bar',
        
'quux',
    ];
}

var_dump((new C)->array);
?>

以上例程在 PHP 5.5 中的輸出:

array(2) {
  [0]=>
  string(3) "bar"
  [1]=>
  string(4) "quux"
}

以上例程在 PHP 5.6 中的輸出:

array(3) {
  [1]=>
  string(3) "foo"
  [2]=>
  string(3) "bar"
  [3]=>
  string(4) "quux"
}

嚴(yán)格的 json_decode()

對于 JSON 字面量 truefalsenull,如果不采用小寫格式,將會被 json_decode() 函數(shù)拒絕, 同時相應(yīng)的設(shè)置 json_last_error()。 在之前的版本中,json_decode() 函數(shù)可以接受這些字面量的 全部大寫或者大小寫混寫的格式。

此變更僅會影響傳入到 json_decode() 中的 JSON 格式無效的情況, 有效的 JSON 輸入不會受到影響并且能夠正確解析。

當(dāng)使用 SSL/TLS 的時候,流封裝器默認(rèn)驗證端點證書和主機名

All encrypted client streams now enable peer verification by default. By default, this will use OpenSSL's default CA bundle to verify the peer certificate. In most cases, no changes will need to be made to communicate with servers with valid SSL certificates, as distributors generally configure OpenSSL to use known good CA bundles.

The default CA bundle may be overridden on a global basis by setting either the openssl.cafile or openssl.capath configuration setting, or on a per request basis by using the cafile or capath context options.

While not recommended in general, it is possible to disable peer certificate verification for a request by setting the verify_peer context option to false, and to disable peer name validation by setting the verify_peer_name context option to false.

GMP 資源現(xiàn)為對象

GMP 資源現(xiàn)為對象。 GMP 擴(kuò)展中的基于函數(shù)的 API 實現(xiàn)不受影響, 只有在代碼中使用 is_resource() 或類似函數(shù) 來顯示檢測是否資源類型的代碼才會受到影響。

Mcrypt 函數(shù)需要有效長度的密鑰和初始向量

mcrypt_encrypt(),mcrypt_decrypt(), mcrypt_cbc()mcrypt_cfb(), mcrypt_ecb(),mcrypt_generic() 以及 mcrypt_ofb() 函數(shù)不再接受無效長度的密鑰和初始向量, 對于需要初始向量的分組加密模式,如果不提供初始向量,函數(shù)調(diào)用將會失敗。

cURL 文件上傳

必須先設(shè)置 CURLOPT_SAFE_UPLOAD 為 false 才能夠使用 @file 語法來上傳文件。 建議使用 CURLFile 類來上傳文件。