雖然大部分 PHP 5 的代碼無(wú)需修改即可正常運行, 但是有部分代碼是無(wú)法向后兼容的:
在 PHP 5.6 之前的版本中,為類(lèi)定義數組類(lèi)型的屬性時(shí), 如果數組中同時(shí)使用了顯式數組鍵和隱式數組鍵,并且顯式的鍵和隱式的序列鍵相同, 那么數組的鍵將被覆蓋。例如:
<?php
class C {
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" }
對于 JSON 字面量 true
,false
和
null
,如果不采用小寫(xiě)格式,將會(huì )被 json_decode() 函數拒絕,
同時(shí)相應的設置 json_last_error()。
在之前的版本中,json_decode() 函數可以接受這些字面量的
全部大寫(xiě)或者大小寫(xiě)混寫(xiě)的格式。
此變更僅會(huì )影響傳入到 json_decode() 中的 JSON 格式無(wú)效的情況, 有效的 JSON 輸入不會(huì )受到影響并且能夠正確解析。
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 資源現為對象。 GMP 擴展中的基于函數的 API 實(shí)現不受影響, 只有在代碼中使用 is_resource() 或類(lèi)似函數 來(lái)顯示檢測是否資源類(lèi)型的代碼才會(huì )受到影響。
mcrypt_encrypt(),mcrypt_decrypt(), mcrypt_cbc(),mcrypt_cfb(), mcrypt_ecb(),mcrypt_generic() 以及 mcrypt_ofb() 函數不再接受無(wú)效長(cháng)度的密鑰和初始向量, 對于需要初始向量的分組加密模式,如果不提供初始向量,函數調用將會(huì )失敗。