2. 新特性
1. Core
- 增加 use group 声明.(RFC: https://wiki.php.net/rfc/group_use_declarations)
- 增加 null coalesce 运算符 ??.(RFC:https://wiki.php.net/rfc/isset_ternary)
- 64位版本支持 >= 2^31字节字符串.
- 增加 Closure::call() 方法(仅对用户类有效).
- 双引号字符串与heredocs中支持使用\u{xxxxxx} Unicode Codepoint Escape 语法声明Unicode字符串.
- define() 现在支持数组作为常量值, 修复const支持数组但define不支持的问题.
- 增加比较操作符 (<=>), 又名太空船操作符.(RFC: https://wiki.php.net/rfc/combined-comparison-operator)
- 增加用于Generators的 yield from 操作符.(RFC: https://wiki.php.net/rfc/generator-delegation)
- 允许在上下文中使用关键词.(RFC: https://wiki.php.net/rfc/context_sensitive_lexer)
- 增加标量类型声明与严格模式(declare(strict_types=1)) (RFC: https://wiki.php.net/rfc/scalar_type_hints_v5)
- 增加接口为用户层提供安全方便的随机数生成器.(RFC: https://wiki.php.net/rfc/easy_userland_csprng)
2. Opcache
增加了基于文件的二级 opcode 缓存机制. 可以在 php.ini 文件中设置
opcache.file_cache=<DIR>
. 当服务重启或者 SHM 重置的时候,使用二级文件缓存机制可以提高性能。.也可以设置
opcache.file_cache_only=1
来限定只使用文件缓存。可以设置
opcache.file_cache_consistency_checks=0
参数来加快加载速度.可以设置
opcache.huge_code_pages=0/1
来决定是否将PHP code pages
放到huage pages
里面. http://www.laruenc e.com/2015/10/02/3069.htmlwindows 版本增加了
opcache.file_cache_fallback=1
配置项.
3. OpenSSL
- 增加了"alpn_pr otoc ols ”选项.
4. Reflection
增加
ReflectionGenerator
类 (yield from Traces, current file/line, etc.)增加
ReflectionType
类以更好支持返回值类型与标量类型声明特性. 新的ReflectionParameter::getType()
与ReflectionFunctionAbstract::getReturnType()
方法均返回ReflectionType
实例.
5. Stream:
windows 版本增加了块读取的选项. 可以通过传递 array("pipe" => array("blocking" => true))
参数来激活.