其他修改

最后更新于:2022-04-01 03:10:12

';

被移除的扩展与 SAPIs

最后更新于:2022-04-01 03:10:09

## Removed Extensions and SAPIs ### Removed Extensions * ereg * mssql * mysql * sybase_ct ### Removed SAPIs * aolserver * apache * apache_hooks * apache2filter * caudium * continuity * isapi * milter * nsapi * phttpd * pi3web * roxen * thttpd * tux * webjames
';

新的全局常量

最后更新于:2022-04-01 03:10:07

## New Global Constants ### [Core Predefined Constants](http://php.net/manual/en/reserved.constants.php) * `PHP_INT_MIN` ### [LibXML](http://php.net/manual/en/book.libxml.php) * `LIBXML_BIGLINES` ### [PCRE](http://php.net/manual/en/book.pcre.php) * `PREG_JIT_STACKLIMIT_ERROR` ### [POSIX](http://php.net/manual/en/book.posix.php) * `POSIX_RLIMIT_AS` * `POSIX_RLIMIT_CORE` * `POSIX_RLIMIT_CPU` * `POSIX_RLIMIT_DATA` * `POSIX_RLIMIT_FSIZE` * `POSIX_RLIMIT_LOCKS` * `POSIX_RLIMIT_MEMLOCK` * `POSIX_RLIMIT_MSGQUEUE` * `POSIX_RLIMIT_NICE` * `POSIX_RLIMIT_NOFILE` * `POSIX_RLIMIT_NPROC` * `POSIX_RLIMIT_RSS` * `POSIX_RLIMIT_RTPRIO` * `POSIX_RLIMIT_RTTIME` * `POSIX_RLIMIT_SIGPENDING` * `POSIX_RLIMIT_STACK` * `POSIX_RLIMIT_INFINITY` ### [Zlib](http://php.net/manual/en/book.zlib.php) * `ZLIB_BLOCK` * `ZLIB_FINISH` * `ZLIB_FULL_FLUSH` * `ZLIB_NO_FLUSH` * `ZLIB_PARTIAL_FLUSH` * `ZLIB_SYNC_FLUSH`
';

新的类与接口

最后更新于:2022-04-01 03:10:05

## New Classes and Interfaces ### [Intl](http://php.net/manual/en/book.intl.php) * [IntlChar](http://php.net/manual/en/class.intlchar.php) ### [Reflection](http://php.net/manual/en/book.reflection.php) * [ReflectionGenerator](http://php.net/manual/en/class.reflectiongenerator.php) * [ReflectionType](http://php.net/manual/en/class.reflectiontype.php) ### [Session Handling](http://php.net/manual/en/book.session.php) * SessionUpdateTimestampHandlerInterface ### Exception Hierarchy * [Throwable](http://php.net/manual/en/class.throwable.php) * [Error](http://php.net/manual/en/class.error.php) * [TypeError](http://php.net/manual/en/class.typeerror.php) * [ParseError](http://php.net/manual/en/class.parseerror.php) * [AssertionError](http://php.net/manual/en/class.assertionerror.php) * [ArithmeticError](http://php.net/manual/en/class.arithmeticerror.php) * [DivisionByZeroError](http://php.net/manual/en/class.divisionbyzeroerror.php)
';

新的函数

最后更新于:2022-04-01 03:10:02

## New functions ### [Closure](http://php.net/manual/en/class.closure.php) * [Closure::call()](http://php.net/manual/en/closure.call.php) ### [CSPRNG](http://php.net/manual/en/book.csprng.php) * [random_bytes()](http://php.net/manual/en/function.random-bytes.php) * [random_int()](http://php.net/manual/en/function.random-int.php) ### [Error Handling and Logging](http://php.net/manual/en/book.errorfunc.php) * [error_clear_last()](http://php.net/manual/en/function.error-clear-last.php) ### [GNU Multiple Precision](http://php.net/manual/en/book.gmp.php) * [gmp_random_seed()](http://php.net/manual/en/function.gmp-random-seed.php) ### [Math](http://php.net/manual/en/book.math.php) * [intdiv()](http://php.net/manual/en/function.intdiv.php) ### [PCRE](http://php.net/manual/en/book.pcre.php) * [preg_replace_callback_array()](http://php.net/manual/en/function.preg-replace-callback-array.php) ### [POSIX](http://php.net/manual/en/book.posix.php) * posix_setrlimit() ### [Reflection](http://php.net/manual/en/book.reflection.php) * [ReflectionParameter::getType()](http://php.net/manual/en/reflectionparameter.gettype.php) * [ReflectionFunctionAbstract::getReturnType()](http://php.net/manual/en/reflectionfunctionabstract.getreturntype.php) ### [Zip](http://php.net/manual/en/book.zip.php) * [ZipArchive::setCompressionIndex()](http://php.net/manual/en/ziparchive.setcompressionindex.php) * [ZipArchive::setCompressionName()](http://php.net/manual/en/ziparchive.setcompressionname.php) ### [Zlib Compression](http://php.net/manual/en/book.zlib.php) * inflate_add() * deflate_add() * inflate_init() * deflate_init()
';

函数变更

最后更新于:2022-04-01 03:10:00

## 函数变更 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Changed-functions.md#php-核心函数)PHP 核心函数 * [debug_zval_dump()](http://php.net/manual/en/function.debug-zval-dump.php) 现在输出int和float类型,对应替代之前的long和double类型 * [dirname()](http://php.net/manual/en/function.dirname.php) 现有第二个参数(depth)可选,基于当前目录获取目录名称深度。 * [getrusage()](http://php.net/manual/en/function.getrusage.php) 不再支持windows系统 * [mktime()](http://php.net/manual/en/function.mktime.php) 及 [gmmktime()](http://php.net/manual/en/function.gmmktime.php) 不再接受 is_dst 参数。 * [preg_replace()](http://php.net/manual/en/function.preg-replace.php) 不再支持`\e (PREG_REPLACE_EVAL)`. 以 `preg_replace_callback()` 作为替代。 * [setlocale()](http://php.net/manual/en/function.setlocale.php) 第一个参数不再接受字符串。必须用 `LC_*` 系列常亮代替。 * exec()、system()、passthru() 函数现在具备空字节保护。
';

7.0.x 版本开始停用的特性

最后更新于:2022-04-01 03:09:58

## 7.0.x 版本开始停用的特性 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Deprecated.md#php4-风格的构造函数)PHP4 风格的构造函数 在 PHP4 中类中的函数可以与类名同名,这一特性在 PHP7 中被废弃,同时会发出一个 E_DEPRECATED 错误。当方法名与类名相同,且类不在命名空间中,同时PHP5的构造函数(__construct)不存在时,会产生一个 E_DEPRECATED 错误。 ~~~ <?php class foo { function foo() { echo 'I am the constructor'; } } ?> ~~~ 上述代码输出: ~~~ Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; foo has a deprecated constructor in example.php on line 3 ~~~ ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Deprecated.md#password_hash-随机因子选项)password_hash() 随机因子选项 函数原 salt 量不再需要由开发者提供了。函数内部默认带有 salt 能力,无需开发者提供 salt 值。
';

SAPI 中的改动

最后更新于:2022-04-01 03:09:55

## SAPI 中的改动 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Sapi-changes.md#fpm)[FPM](http://php.net/manual/en/book.fpm.php) * Fixed bug #65933 (Cannot specify config lines longer than 1024 bytes). * Listen = port now listen on all addresses (IPv6 and IPv4-mapped).
';

新的特性

最后更新于:2022-04-01 03:09:53

## 新的特性 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#标量类型声明)标量类型声明 标量类型声明有两种模式:强制(默认)模式、严格模式。下列参数类型可以使用(无论用强制模式还是严格模式):字符串(string)、整形(int)、浮点数(float)和布尔型(bool)。其他类型在 PHP5 中有支持:类名、接口、数组和可被调用的。 ~~~ <?php // Coercive mode function sumOfInts(int ...$ints) { return array_sum($ints); } var_dump(sumOfInts(2, '3', 4.1)); ~~~ 上述例子输出: ~~~ int(9) ~~~ 当开启严格模式后,一个 [declare](http://php.net/manual/en/control-structures.declare.php) 声明必须置于 PHP 脚本文件开头,这意味着严格声明标量是基于文件可配的。这个指令不仅影响参数的类型声明,也影响到函数的返回值声明(详见下面的返回值声明)。 详细的标量类型声明的文档与示例,可以查看[类型声明](http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration)页面。 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#返回类型声明)返回类型声明 PHP7 新增了返回类型声明,类似于参数类型声明,返回类型声明提前声明了函数返回值的类型。可用的声明类型与参数声明中可用的类型相同。 ~~~ <?php function arraysSum(array ...$arrays): array { return array_map(function(array $array): int { return array_sum($array); }, $arrays); } print_r(arraysSum([1,2,3], [4,5,6], [7,8,9])); ~~~ 上述代码返回值为: ~~~ Array ( [0] => 6 [1] => 15 [2] => 24 ) ~~~ 详细的返回值声明相关的文档和示例代码可以查阅[返回值声明](http://php.net/manual/en/functions.returning-values.php#functions.returning-values.type-declaration)文档。 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#null合并算子操作符)NULL合并算子(操作符“??”) 空合并算子的操作符为 `??` ,已经作为一种语法糖用于日常需求中用于三元表达式,它与 isset() 同时发生。如果变量存在且不为空,它就会返回对应的值,相反,它返回它的第二个操作数。 ~~~ <?php // Fetches the value of $_GET['user'] and returns 'nobody' // if it does not exist. $username = $_GET['user'] ?? 'nobody'; // This is equivalent to: $username = isset($_GET['user']) ? $_GET['user'] : 'nobody'; // Coalesces can be chained: this will return the first // defined value out of $_GET['user'], $_POST['user'], and // 'nobody'. $username = $_GET['user'] ?? $_POST['user'] ?? 'nobody'; ?> ~~~ ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#太空船操作符组合比较符rfc)太空船操作符(组合比较符,[RFC](https://wiki.php.net/rfc/combined-comparison-operator)) 太空船操作符用于比较两个表达式。它返回一个大于 0、等于 0、小于 0 的数,用于表示 $a 与 $b 之间的关系。比较的原则是沿用 PHP 的[常规比较规则](http://php.net/manual/en/types.comparisons.php)进行的。 ~~~ <?php // Integers echo 1 <=> 1; // 0 echo 1 <=> 2; // -1 echo 2 <=> 1; // 1 // Floats echo 1.5 <=> 1.5; // 0 echo 1.5 <=> 2.5; // -1 echo 2.5 <=> 1.5; // 1 // Strings echo "a" <=> "a"; // 0 echo "a" <=> "b"; // -1 echo "b" <=> "a"; // 1 ?> ~~~ ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#通过-define-定义常量数组)通过 define() 定义常量数组 Array 类型的常量可以通过 define() 来定义。在 PHP5.6 中仅能通过 const 定义。 ~~~ <?php define('ANIMALS', [ 'dog', 'cat', 'bird' ]); echo ANIMALS[1]; // outputs "cat" ?> ~~~ ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#匿名类)匿名类 可以通过 new 关键字初始化一个匿名类。匿名类使用场景与完整的类场景相同。 ~~~ <?php interface Logger { public function log(string $msg); } class Application { private $logger; public function getLogger(): Logger { return $this->logger; } public function setLogger(Logger $logger) { $this->logger = $logger; } } $app = new Application; $app->setLogger(new class implements Logger { public function log(string $msg) { echo $msg; } }); var_dump($app->getLogger()); ?> ~~~ 上面代码输出: ~~~ object(class@anonymous)#2 (0) { } ~~~ 详细文档可以参考[匿名类文档](http://php.net/manual/en/language.oop5.anonymous.php) ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#unicode-codepoint-转译语法)Unicode codepoint 转译语法 通过十六进制内容与双引号组成的字符串生成 Unicode codepoint,可以接受任何有效的 codepoint,并且开头的 0 是可以省略的。 ~~~ echo "\u{aa}"; echo "\u{0000aa}"; echo "\u{9999}"; ~~~ 上面代码输出: ~~~ (same as before but with optional leading 0's) ~~~ ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#closurecall)[Closure::call()](http://php.net/manual/en/closure.call.php) 闭包 [Closure::call()](http://php.net/manual/en/closure.call.php) 有着更好的性能,简短干练的暂时绑定一个方法到对象上闭包并调用它。 ~~~ <?php class A {private $x = 1;} // Pre PHP 7 code $getXCB = function() {return $this->x;}; $getX = $getXCB->bindTo(new A, 'A'); // intermediate closure echo $getX(); // PHP 7+ code $getX = function() {return $this->x;}; echo $getX->call(new A); ~~~ 上述代码输出: ~~~ 1 1 ~~~ ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#为-unserialize-提供过滤)为 unserialize() 提供过滤 这个特性意在提供更安全的方式解包不可靠的数据。通过白名单的方式来防止代码注入。 ~~~ <?php // converts all objects into __PHP_Incomplete_Class object $data = unserialize($foo, ["allowed_classes" => false]); // converts all objects into __PHP_Incomplete_Class object except those of MyClass and MyClass2 $data = unserialize($foo, ["allowed_classes" => ["MyClass", "MyClass2"]); // default behaviour (same as omitting the second argument) that accepts all classes $data = unserialize($foo, ["allowed_classes" => true]); ~~~ ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#intlchar)[IntlChar](http://php.net/manual/en/class.intlchar.php) 新增加的 IntlChar 类意在于暴露出更多的 ICU 功能。类自身定义了许多静态方法用于操作 unicode 字符。 ~~~ <?php printf('%x', IntlChar::CODEPOINT_MAX); echo IntlChar::charName('@'); var_dump(IntlChar::ispunct('!')); ~~~ 上述代码输出: ~~~ 10ffff COMMERCIAL AT bool(true) ~~~ 若要使用此类,请先安装Intl扩展。 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#预期-增强的断言)预期 (增强的断言) 预期(增强的断言)是向后兼用以增强 assert() 方法。在代码中启用断言为零成本,并且提供抛出特定异常的能力。 在使用老版本 API 时,如果第一个参数是一个字符串,那么它将被解析。第二个参数可以是一个简单的字符串(导致 AssertionError 被触发),或一个包含一个错误消息的自定义异常对象。 ~~~ <?php ini_set('assert.exception', 1); class CustomError extends AssertionError {} assert(false, new CustomError('Some error message')); ~~~ 上述代码输出: ~~~ Fatal error: Uncaught CustomError: Some error message ~~~ 这个特性会带来两个 PHP.ini 设置(以及它们的默认值): * zend.assertions = 1 * assert.exception = 0 zend.assertions 有三种值: * 1 = 生成并且执行代码(开发模式) * 0 = 执行代码并且在运行期间跳来跳去 * -1 = 不生成任何代码 (0开销, 生产模式) assert.exception 意味着断言失败时抛出异常。默认关闭保持兼容旧的 assert() 函数。 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#使用-use-集体声明)使用 use 集体声明 在 PHP7 之前需要声明一大堆命名空间,但是现在可以通过 use 的新特性,批量声明。 ~~~ <?php // Pre PHP 7 code use some\namespace\ClassA; use some\namespace\ClassB; use some\namespace\ClassC as C; use function some\namespace\fn_a; use function some\namespace\fn_b; use function some\namespace\fn_c; use const some\namespace\ConstA; use const some\namespace\ConstB; use const some\namespace\ConstC; // PHP 7+ code use some\namespace\{ClassA, ClassB, ClassC as C}; use function some\namespace\{fn_a, fn_b, fn_c}; use const some\namespace\{ConstA, ConstB, ConstC}; ~~~ ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#generator-return-expressions)Generator Return Expressions This feature builds upon the generator functionality introduced into PHP 5.5\. It enables for a return statement to be used within a generator to enable for a final expression to be returned (return by reference is not allowed). This value can be fetched using the new Generator::getReturn() method, which may only be used once the generator has finishing yielding values. ~~~ <?php $gen = (function() { yield 1; yield 2; return 3; })(); foreach ($gen as $val) { echo $val, PHP_EOL; } echo $gen->getReturn(), PHP_EOL; ~~~ 上述代码输出: ~~~ 1 2 3 ~~~ Being able to explicitly return a final value from a generator is a handy ability to have. This is because it enables for a final value to be returned by a generator (from perhaps some form of coroutine computation) that can be specifically handled by the client code executing the generator. This is far simpler than forcing the client code to firstly check whether the final value has been yielded, and then if so, to handle that value specifically. ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#generator-delegation)Generator Delegation Generator delegation builds upon the ability of being able to return expressions from generators. It does this by using an new syntax of yield from , where can be any Traversable object or array. This will be advanced until no longer valid, and then execution will continue in the calling generator. This feature enables yield statements to be broken down into smaller operations, thereby promoting cleaner code that has greater reusability. ~~~ <?php function gen() { yield 1; yield 2; return yield from gen2(); } function gen2() { yield 3; return 4; } $gen = gen(); foreach ($gen as $val) { echo $val, PHP_EOL; } echo $gen->getReturn(); ~~~ 上述代码输出: ~~~ 1 2 3 4 ~~~ ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#通过-intdiv-做整除)通过 intdiv() 做整除 intdiv() 函数来处理整除,并返回一个整数。 ~~~ <?php var_dump(intdiv(10, 3)); ~~~ 上述代码输出: ~~~ int(3) ~~~ ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#session_start-选项)session_start() 选项 该特性给 session_start() 函数提供一些设置能力,当然这些设置可以在 PHP.ini 中设置。 ~~~ <?php session_start(['cache_limiter' => 'private']); // sets the session.cache_limiter option to private ~~~ 这个特性还引入了一个新的 php.ini 设置( session.lazy_write ),默认情况下为 true,表示改变会话数据只是重写。 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#preg_replace_callback_array-函数)preg_replace_callback_array() 函数 这个新功能,当你使用 preg_replace_callback() 函数时代码更清晰可读。在PHP7之前,每个正则表达式都需要回调( preg_replace_callback() 函数的第二个参数 )中来实现功能,这会使流程混乱不可控。 现在,回调可以通过与正则表达式绑定着写,只需将正则表达式作为 key,回调函数作为 value。 ~~~ <?php $tokenStream = []; // [tokenName, lexeme] pairs $input = <<<'end' $a = 3; // variable initialisation end; // Pre PHP 7 code preg_replace_callback( [ '~\$[a-z_][a-z\d_]*~i', '~=~', '~[\d]+~', '~;~', '~//.*~' ], function ($match) use (&$tokenStream) { if (strpos($match[0], '$') === 0) { $tokenStream[] = ['T_VARIABLE', $match[0]]; } elseif (strpos($match[0], '=') === 0) { $tokenStream[] = ['T_ASSIGN', $match[0]]; } elseif (ctype_digit($match[0])) { $tokenStream[] = ['T_NUM', $match[0]]; } elseif (strpos($match[0], ';') === 0) { $tokenStream[] = ['T_TERMINATE_STMT', $match[0]]; } elseif (strpos($match[0], '//') === 0) { $tokenStream[] = ['T_COMMENT', $match[0]]; } }, $input ); // PHP 7+ code preg_replace_callback_array( [ '~\$[a-z_][a-z\d_]*~i' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_VARIABLE', $match[0]]; }, '~=~' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_ASSIGN', $match[0]]; }, '~[\d]+~' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_NUM', $match[0]]; }, '~;~' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_TERMINATE_STMT', $match[0]]; }, '~//.*~' => function ($match) use (&$tokenStream) { $tokenStream[] = ['T_COMMENT', $match[0]]; } ], $input ); ~~~ ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#csprng-系列函数)[CSPRNG](http://php.net/manual/en/book.csprng.php) 系列函数 该特性涵盖两个函数,用于生成安全的整形与字符串,主要用于密码场景。它提供了简单的 API 和平台无关性。 ~~~ string random_bytes(int length); int random_int(int min, int max); ~~~ 两个函数在没有足够的随机性时会报 E_WARNING 错误并且返回 false。 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md#list-可以打开对象实现-arrayaccess)list() 可以打开对象实现 [ArrayAccess](http://php.net/manual/en/class.arrayaccess.php)
';

向后兼容说明

最后更新于:2022-04-01 03:09:51

### 错误和异常处理的变更 许多可以被修正的 Fatal 错误,在 PHP7 中将以 Exceptions 异常的形式抛出。这些 Error Exceptions 继承于 [Error](http://php.net/manual/en/class.error.php) 类。而[Error](http://php.net/manual/en/class.error.php) 类则实现了异常基类 [Throwable](http://php.net/manual/en/class.throwable.php) 接口。  PHP7 中详细的 Error 信息可以参考 [PHP7 错误](http://php.net/manual/en/language.errors.php7.php) 。本文中仅仅介绍和向后兼容有关的信息如下。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#类构造函数在失败时抛出异常)类构造函数在失败时抛出异常 之前,类构造函数在失败时总是返回NULL或者返回一个不可用的 Object,但从 PHP7 开始,在构造函数初始化失败时会抛出[异常](http://php.net/manual/en/class.exception.php)。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#解析错误时会抛出-解析异常)解析错误时会抛出 [解析异常](http://php.net/manual/en/class.parseerror.php) 现在,解析 [eval()](http://php.net/manual/en/function.eval.php) 错误会抛出一个 [解析异常](http://php.net/manual/en/class.parseerror.php) 对象。其可以通过 [catch](http://php.net/manual/en/language.exceptions.php#language.exceptions.catch) 捕捉,并做相应处理。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#e_strict-等级的报错被重新分配)E_STRICT 等级的报错被重新分配 所有 **E_STRICT** 级别的报错已重新分配到其他报错等级中。**E_STRICT** 常量依然保留,所以当你设置报错等级为**error_reporting(E_ALL|E_STRICT)** 时,不会引起报错。 变更情况如下表 [![image](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-09-11_55f24d39112dc.png)](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-09-11_55f24d39112dc.png) ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#变量处理环节的变更)变量处理环节的变更 由于 PHP7 采用抽象的语法树解析代码文件,并且过去的 PHP 版本无法满足该特性,这一变化将引起一些一致性问题。本节详细介绍这块的情况。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#对于间接变量属性方法的变动)对于间接变量、属性、方法的变动 间接的使用变量、属性、方法,将严格按照从左到右的顺序执行,而不会因形式问题导致歧义。下表将表明这一改变引起的差异。 [![image](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-09-11_55f24d3b79f95.png)](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-09-11_55f24d3b79f95.png)以上使用老的从右到左的方式的代码,将被重写。通过花括号来明确顺序(见上图中间列),使代码向前兼容 PHP7.x,并向后兼容 PHP5.x。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#对于-list-函数处理上的修改)对于 [list()](http://php.net/manual/en/function.list.php) 函数处理上的修改 ##### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#list-不再按照相反顺序插入元素)[list()](http://php.net/manual/en/function.list.php) 不再按照相反顺序插入元素 [list()](http://php.net/manual/en/function.list.php) 函数从此开始按照原数组中的顺序插入到函数参数制定的位置上,不再翻转数据。这点修改只会作用在 [list()](http://php.net/manual/en/function.list.php) 函数参数一起用了数组的 `[]` 符号时。举例如下: ~~~ <?php list($a[], $a[], $a[]) = [1, 2, 3]; var_dump($a); ?> ~~~ 上述例子在 PHP5 中的输出为: ~~~ array(3) { [0]=> int(3) [1]=> int(2) [2]=> int(1) } ~~~ 而在 PHP7 中的输出为: ~~~ array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } ~~~ 在实际开发中,不建议使用依靠 [list()](http://php.net/manual/en/function.list.php) 函数的参数来做排顺序这一操作,毕竟这样的 hack 用法在未来依然有可能被调整。 ##### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#list-函数参数不再允许为空)[list()](http://php.net/manual/en/function.list.php) 函数参数不再允许为空 [list()](http://php.net/manual/en/function.list.php) 构造时不再允许参数为空的情况,下列情况将不再支持! ~~~ <?php list() = $a; list(,,) = $a; list($x, list(), $y) = $a; ?> ~~~ ##### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#list-函数不再支持拆解字符串)[list()](http://php.net/manual/en/function.list.php) 函数不再支持拆解字符串 [list()](http://php.net/manual/en/function.list.php) 不再允许拆解[字符串](http://php.net/manual/en/language.types.string.php)变量为字母,[str_split](http://php.net/manual/en/function.str-split.php) 函数可以用于做此事。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#在数组中的元素通过引用方式创建时数组顺序会被改变)在数组中的元素通过引用方式创建时,数组顺序会被改变 数组中的元素在通过引用方式创建时,其数组顺序会被自动的改变。例如: ~~~ <?php $array = []; $array["a"] =& $array["b"]; $array["b"] = 1; var_dump($array); ?> ~~~ PHP5 中的输出: ~~~ array(2) { ["b"]=> &int(1) ["a"]=> &int(1) } ~~~ PHP7 中的输出 ~~~ array(2) { ["a"]=> &int(1) ["b"]=> &int(1) } ~~~ #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#global-仅支持简单的变量)[global](http://php.net/manual/en/language.variables.scope.php#language.variables.scope.global) 仅支持简单的变量 [可变变量](http://php.net/manual/en/language.variables.variable.php)将不能再使用 [global](http://php.net/manual/en/language.variables.scope.php#language.variables.scope.global) 标记。如果真的需要,可以用花括号来间隔开写,例如下面代码: ~~~ <?php function f() { // Valid in PHP 5 only. global $$foo->bar; // Valid in PHP 5 and 7. global ${$foo->bar}; } ?> ~~~ 作为一个基本原则,这样的变量套变量的使用方式,在 [global](http://php.net/manual/en/language.variables.scope.php#language.variables.scope.global) 这种场景下不被提倡。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#函数参数中的括号不再影响行为)函数参数中的括号不再影响(行为?) 在 PHP5 中,函数引用参数如果匹配括号操作,不会触发严格标准警告。但从 PHP7 开始,这种场景都会引发一个警告信息。 ~~~ <?php function getArray() { return [1, 2, 3]; } function squareArray(array &$a) { foreach ($a as &$v) { $v **= 2; } } // Generates a warning in PHP 7. squareArray((getArray())); ?> ~~~ 上述示例代码将会产生如下输出: ~~~ Notice: Only variables should be passed by reference in /tmp/test.php on line 13 ~~~ ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#foreach-的改变)[foreach](http://php.net/manual/en/control-structures.foreach.php) 的改变 关于 [foreach](http://php.net/manual/en/control-structures.foreach.php) 的修改比较少,主要是修改了数组遍历时的数组指针,以及修改了数组的迭代。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#foreach-遍历期间不再修改数组指针)[foreach](http://php.net/manual/en/control-structures.foreach.php) 遍历期间不再修改数组指针 在 PHP7 之前,当数组通过 [foreach](http://php.net/manual/en/control-structures.foreach.php) 迭代时,数组指针会移动。现在开始,不再如此,见下面代码: ~~~ <?php $array = [0, 1, 2]; foreach ($array as &$val) { var_dump(current($array)); } ?> ~~~ PHP5 中的输出 ~~~ int(1) int(2) bool(false) ~~~ PHP7 中的输出 ~~~ int(0) int(0) int(0) ~~~ #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#foreach-通过值遍历时操作的值为数组的副本)[foreach](http://php.net/manual/en/control-structures.foreach.php) 通过值遍历时,操作的值为数组的副本 当默认使用通过值遍历数组时,[foreach](http://php.net/manual/en/control-structures.foreach.php) 实际操作的是数组的迭代副本,而非数组本身。这就意味着,[foreach](http://php.net/manual/en/control-structures.foreach.php) 中的操作不会修改原数组的值。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#foreach-通过引用遍历时有更好的迭代特性)[foreach](http://php.net/manual/en/control-structures.foreach.php) 通过引用遍历时,有更好的迭代特性 当使用引用遍历数组时,现在 [foreach](http://php.net/manual/en/control-structures.foreach.php) 在迭代中能更好的跟踪变化。例如,在迭代中添加一个迭代值到数组中,例如下面代码: ~~~ <?php $array = [0]; foreach ($array as &$val) { var_dump($val); $array[1] = 1; } ?> ~~~ 在 PHP5 的输出为: ~~~ int(0) ~~~ 在 PHP7 的输出为: ~~~ int(0) int(1) ~~~ #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#non-traversable-对象的遍历)[non-Traversable](http://php.net/manual/en/class.traversable.php) 对象的遍历 [non-Traversable](http://php.net/manual/en/class.traversable.php) 对象的遍历与通过引用遍历相似,具有相同的行为特性,[在遍历期间对原数据进行的操作将会被感知](http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.foreach.by-ref)。 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#整型处理上的调整)[整型](http://php.net/manual/en/language.types.integer.php)处理上的调整 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#无效的八进制常量)无效的八进制常量 此前,八进制中包含无效数据会自动被截断(0128 被当做为 012)。现在,一个无效的八进制字面会造成分析错误。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#负位置)负位置 位移的负数将抛出一个 [ArithmeticError](http://php.net/manual/en/class.arithmeticerror.php) ~~~ <?php var_dump(1 >> -1); ?> ~~~ PHP5 中的输出: ~~~ int(0) ~~~ PHP7 中的输出: ~~~ Fatal error: Uncaught ArithmeticError: Bit shift by negative number in /tmp/test.php:2 Stack trace: #0 {main} thrown in /tmp/test.php on line 2 ~~~ #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#超出范围的位移)超出范围的位移 位移(任一方向)超出一个整数的位宽度会得到 0。以前,这种转变的行为是依赖于运行环境的机器架构结构。 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#字符串处理上的调整)[字符串](http://php.net/manual/en/language.types.string.php)处理上的调整 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#十六进制字符串不再被认为是数字)十六进制字符串不再被认为是数字 含十六进制字符串不再被认为是数字。例如: ~~~ <?php var_dump("0x123" == "291"); var_dump(is_numeric("0x123")); var_dump("0xe" + "0x1"); var_dump(substr("foo", "0x1")); ?> ~~~ 在 PHP5 中的输出: ~~~ bool(true) bool(true) int(15) string(2) "oo" ~~~ 在 PHP7 中的输出: ~~~ bool(false) bool(false) int(0) Notice: A non well formed numeric value encountered in /tmp/test.php on line 5 string(3) "foo" ~~~ [filter_var()](http://php.net/manual/en/function.filter-var.php) 函数可以用于检查一个字符串中是否包含十六进制数,同时也可以转换一个字符串为十六进制数。 ~~~ <?php $str = "0xffff"; $int = filter_var($str, FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_HEX); if (false === $int) { throw new Exception("Invalid integer!"); } var_dump($int); // int(65535) ?> ~~~ #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#u-可能触发错误)\u{ 可能触发错误 由于新的 [Unicode 转译语法](http://php.net/manual/en/migration70.new-features.php#migration70.new-features.unicode-codepoint-escape-syntax),字符串中含有 **\u{ ** 时会触发Fatal错误。为了避免这一报错,应该避免反斜杠开头。 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#被移除的函数)被移除的函数 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#call_user_method-与-call_user_method_array)[call_user_method()](http://php.net/manual/en/function.call-user-method.php) 与 [call_user_method_array()](http://php.net/manual/en/function.call-user-method-array.php) 这些函数被在 PHP4.1.0 开始被标记为过时的,在 PHP7 开始被删除。建议使用 [call_user_func()](http://php.net/manual/en/function.call-user-func.php) 和 [call_user_func_array()](http://php.net/manual/en/function.call-user-func-array.php)。你可以考虑下[变量函数](http://php.net/manual/en/functions.variable-functions.php)或者参考其他函数。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#mcrypt-相关)[mcrypt](http://php.net/manual/en/book.mcrypt.php) 相关 [mcrypt_generic_end()](http://php.net/manual/en/function.mcrypt-generic-end.php) 被删除,建议使用 [mcrypt_generic_deinit()](http://php.net/manual/en/function.mcrypt-generic-deinit.php) 。 此外,废弃的[mcrypt_ecb()](http://php.net/manual/en/function.mcrypt-ecb.php),[mcrypt_cbc()](http://php.net/manual/en/function.mcrypt-cbc.php),[mcrypt_cfb()](http://php.net/manual/en/function.mcrypt-cfb.php) 和 [mcrypt_ofb()](http://php.net/manual/en/function.mcrypt-ofb.php) 功能,建议使用目前还支持的 [mcrypt_decrypt()](http://php.net/manual/en/function.mcrypt-decrypt.php) 与适当的 MCRYPT_MODE_* 常量。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#intl-相关)[intl](http://php.net/manual/en/book.intl.php) 相关 [datefmt_set_timezone_id()](http://php.net/manual/en/intldateformatter.settimezoneid.php) 与 [IntlDateFormatter::setTimeZoneID()](http://php.net/manual/en/intldateformatter.settimezoneid.php) 被删除,建议使用 [datefmt_set_timezone()](http://php.net/manual/en/intldateformatter.settimezone.php) 与[IntlDateFormatter::setTimeZone()](http://php.net/manual/en/intldateformatter.settimezone.php) 。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#set_magic_quotes_runtime)[set_magic_quotes_runtime()](http://php.net/manual/en/function.set-magic-quotes-runtime.php) [set_magic_quotes_runtime()](http://php.net/manual/en/function.set-magic-quotes-runtime.php) 与它的别名函数 [magic_quotes_runtime()](http://php.net/manual/en/function.magic-quotes-runtime.php) 被删除。他们在 PHP5.3.0 中就被标记被过时的。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#set_socket_blocking)[set_socket_blocking()](http://php.net/manual/en/function.set-socket-blocking.php) [set_socket_blocking()](http://php.net/manual/en/function.set-socket-blocking.php) 已被移除,建议使用 [stream_set_blocking()](http://php.net/manual/en/function.stream-set-blocking.php)。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#dl-在php-fpm中)[dl()](http://php.net/manual/en/function.dl.php) 在PHP-FPM中 [dl()](http://php.net/manual/en/function.dl.php) 函数不能在 PHP-FPM 中使用了,它的功能做在了 CLI、嵌入到 SAPIs 中了。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#gd-类型的函数)[GD](http://php.net/manual/en/book.image.php) 类型的函数 PostScript Type1 字体的支持已经从 GD 扩展删除,涉及的函数有: * imagepsbbox() * imagepsencodefont() * imagepsextendfont() * imagepsfreefont() * imagepsloadfont() * imagepsslantfont() * imagepstext() 建议使用 TrueType 字体和其相关的功能代替。 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#删除ini配置)删除INI配置 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#删除的功能)删除的功能 下面的INI指令以及相关的功能被删除: * [always_populate_raw_post_data](http://php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data) * [asp_tags](http://php.net/manual/en/ini.core.php#ini.asp-tags) #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#xslsecurity_prefs)xsl.security_prefs xsl.security_prefs 指令已被删除。相反,该 [xsltprocessor::setsecurityprefs()](http://php.net/manual/en/xsltprocessor.setsecurityprefs.php) 方法用于控制在每个处理器上的安全选项。 ### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#其他不向后兼容的变更)其他不向后兼容的变更 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#new-对象不能被引用分配)[New](http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.new) 对象不能被引用分配 [New](http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.new) 语句的结果不再能通过引用赋值给一个变量,如下代码: ~~~ <?php class C {} $c =& new C; ?> ~~~ PHP5 中的输出: ~~~ Deprecated: Assigning the return value of new by reference is deprecated in /tmp/test.php on line 3 ~~~ PHP7 中的输出: ~~~ Parse error: syntax error, unexpected 'new' (T_NEW) in /tmp/test.php on line 3 ~~~ #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#无效的类接口和特性的名字)无效的类、接口和特性的名字 下面的名称不能被用来作为类、接口、特性的名称: * bool * int * float * string * NULL * TRUE * FALSE 此外,不推荐下列名称,它们已被标记为过时 * resource * object * mixed * numeric #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#asp-语法标记script-php-语法标记被移除)ASP 语法标记、Script PHP 语法标记被移除 使用 ASP 脚本标签,或者 Script 的 PHP 代码,已被删除。受影响的标签是: [![image](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-09-11_55f24d3c12688.png)](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2015-09-11_55f24d3c12688.png) #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#禁止调用不确定的情况)禁止调用不确定的情况 [之前 PHP5.6 的过时说明中](http://php.net/manual/en/migration56.deprecated.php#migration56.deprecated.incompatible-context),静态调用一个非静态方法,会在静态调用中被提示未定义 $this ,并会报错。 ~~~ <?php class A { public function test() { var_dump($this); } } // Note: Does NOT extend A class B { public function callNonStaticMethodOfA() { A::test(); } } (new B)->callNonStaticMethodOfA(); ?> ~~~ 在 PHP5 中会输出: ~~~ Deprecated: Non-static method A::test() should not be called statically, assuming $this from incompatible context in /tmp/test.php on line 8 object(B)#1 (0) { } ~~~ 在 PHP7 中会输出: ~~~ Deprecated: Non-static method A::test() should not be called statically in /tmp/test.php on line 8 Notice: Undefined variable: this in /tmp/test.php on line 3 NULL ~~~ #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#yield-现在开始作为右关联运算符)[yield](http://php.net/manual/en/language.generators.syntax.php#control-structures.yield) 现在开始作为(右)关联运算符 [yield](http://php.net/manual/en/language.generators.syntax.php#control-structures.yield) 不再需要括号,可以作为一个(右)关联运算符,优先于 `print` 与 `=>`,这将产生下列行为: ~~~ <?php echo yield -1; // Was previously interpreted as echo (yield) - 1; // And is now interpreted as echo yield (-1); yield $foo or die; // Was previously interpreted as yield ($foo or die); // And is now interpreted as (yield $foo) or die; ?> ~~~ 括号可以用来消除歧义的情况。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#函数不能有多个相同的名称的参数)函数不能有多个相同的名称的参数 不允许函数在参数中出现相同名称的参数。例如下列代码,将会产生 **E_COMPILE_ERROR** 的报错。 ~~~ <?php function foo($a, $b, $unused, $unused) { // } ?> ~~~ #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#http_raw_post_data-被移除)[$HTTP_RAW_POST_DATA](http://php.net/manual/en/reserved.variables.httprawpostdata.php) 被移除 `$HTTP_RAW_POST_DATA` 不再被支持。 可以使用 php://input 流数据来代替实现。 #### [](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md#-注释已被移除)# 注释已被移除 INI 文件中以 # 符号作为注释的内容已被移除,**;** 符号将代替 **#**,这个改变同样适用于 `PHP.ini` 文件,以及 [parse_ini_file()](http://php.net/manual/en/function.parse-ini-file.php)和 [parse_ini_string()](http://php.net/manual/en/function.parse-ini-string.php) 处理文件期间。
';

关于

最后更新于:2022-04-01 03:09:49

> 原文出处:https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x ## PHP7 依然处于开发中 >[danger] [警告] > PHP7 目前仍处于开发中并且短时间内还不能完成,本文中的一些新 > 特性、修改还需等 7.0 版本正式发布后才能敲定(还有可能修改)。 > 请你在将 PHP7 部署到线上生成环境之前再来确认下最新的变更是否 > 对你的业务有影响。 PHP7 是一个全新的大版本,我们在努力让大家做到无缝的升级。这次版本变更专注在移除旧特性以保证语言的一致性。 这里有一些已经被确定的[不兼容](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/Backward-incompatible-changes.md)和[新特性](https://github.com/pangee/Migrating-from-PHP5.6.x-to-PHP7.0.x/blob/master/New-features.md),请大家切换生产环境的PHP版本到PHP7之前,这些环节需要特别关注测试。 这里提供一些其他PHP版本的升级指南:[5.0.x](http://php.net/manual/en/migration5.php)、 [5.1.x](http://php.net/manual/en/migration51.php)、 [5.2.x](http://php.net/manual/en/migration52.php)、 [5.3.x](http://php.net/manual/en/migration53.php)、 [5.4.x](http://php.net/manual/en/migration54.php)、 [5.5.x](http://php.net/manual/en/migration55.php)、 和 [5.6.x](http://php.net/manual/en/migration56.php)
';