【PHP】PHP5.4.0版本ChangeLog详解(上)

前言

随着大量的框架使用composer和namespace,渐渐的线上环境也从以前的5.3变成了5.4或者5.5甚至5.6,随着7月份PHP7的发布,会有更多的公司采用新版本。php

以前很久就想写这样的一片文章,来讲明下各个版本的差别,此次算是拿出时间了。html

此次的是第一篇,目前规划写三篇java

  • PHP5.4.0
  • PHP5.5.0
  • PHP5.6.0

一方面是对本身的知识的整理,一方面是对本身的一次提高。web

官方说明

官方文档地址 http://php.net/ChangeLog-5.php#5.4.0算法

详细说明

01 Mar 2012

原文sql

  • autoconf 2.59+ is now supported (and required) for generating the configure script with ./buildconf. Autoconf 2.60+ is desirable otherwise the configure help order may be incorrect.

翻译编程

autoconf 2.59 +如今支持(须要)生成配置脚本/ buildconf。autoconf 2.60 +是理想的配置,不然有多是不正确的。windows

autoconf

php编译安装的时候须要的依赖软件,因此新版本对应配套的软件也要换成最新的对性能来说才保险啊~api

Removed legacy features 移除的特性

原文数组

  • break/continue $var syntax.
  • Safe mode and all related ini options.
  • register_globals and register_long_arrays ini options.
  • import_request_variables().
  • allow_call_time_pass_reference.
  • define_syslog_variables ini option and its associated function.
  • highlight.bg ini option.
  • Session bug compatibility mode (session.bug_compat_42 and session.bug_compat_warn ini options).
  • session_is_registered(), session_register() and session_unregister() functions.
  • y2k_compliance ini option.
  • magic_quotes_gpc, magic_quotes_runtime and magic_quotes_sybase ini options. get_magic_quotes_gpc, get_magic_quotes_runtime are kept but always return false, set_magic_quotes_runtime raises an E_CORE_ERROR.
  • Removed support for putenv(“TZ=..”) for setting the timezone.
  • Removed the timezone guessing algorithm in case the timezone isn’t set with date.timezone or date_default_timezone_set(). Instead of a guessed timezone, “UTC” is now used instead.

翻译

  • break/continue$ var语法。
  • 安全模式和全部相关的INI选项。
  • register_globals和register_long_arrays INI选项。
  • import_request_variables()。
  • allow_call_time_pass_reference。
  • define_syslog_variables INI选项及其相关的功能。
  • highlight.bg INI选项。
  • 会话错误兼容模式(session.bug_compat_42和session.bug_compat_warn INI选项)。
  • session_is_registered(),session_register()和session_unregister()功能。
  • y2k_compliance INI选项。
  • magic_quotes_gpc,magic_quotes_runtime和magic_quotes_sybase INI选项。get_magic_quotes_gpc,get_magic_quotes_runtime保存但始终返回false,set_magic_quotes_runtime引起e_core_error。
  • 再也不支持putenv(“TZ = ..”)设置时区。
  • 若是不设置时区与时区date.timezone或date_default_timezone_set()除去猜想算法。而不是猜想的时区,“UTC”如今是用来代替。

我是拿百度翻译来的我会乱说吗? =_=

break/continue

移除了break/continue $var语法

在5.4以前,咱们能够经过传递后面的参数来控制跳出或者中止若干层的循环,然而在5.4.0的版本以后,就去除了这个特性。

break $c;
continue $c;

break and continue accepts a number, that specify the number of nested loops, that should be breaked up, or continued.

参考资料

PHP 的安全模式是为了试图解决共享服务器(shared-server)安全问题而设立的。在结构上,试图在 PHP 层上解决这个问题是不合理的,但修改 web 服务器层和操做系统层显得很是不现实。所以许多人,特别是 ISP,目前使用安全模式。

语言的发展是在不断的进步的啊,也是一个不断试错改错的过程。^_^

  • 保安措施和安全模式,也就是移除了php.ini中全部safe_mode相关的配置项
  • 被安全模式限制或屏蔽的函数 。 在安全限制模式下,有些函数不能被使用。这个限制也将被移除

参考资料

register_globals and register_long_arrays ini options.

这两个配置项由于性能关系被移除了。

参考资料

import_request_variables()

import_request_variables — 将 GET/POST/Cookie 变量导入到全局做用域中

bool import_request_variables ( string types[,string prefix ] )
将 GET/POST/Cookie 变量导入到全局做用域中。若是你禁止了 register_globals,但又想用到一些全局变量,那么此函数就颇有用。

你可使用 types 参数指定须要导入的变量。能够用字母‘G’、‘P’和‘C’分别表示 GET、POST 和 Cookie。这些字母不区分大小写,因此你可使用‘g’、‘p’和‘c’的任何组合。POST 包含了经过 POST 方法上传的文件信息。注意这些字母的顺序,当使用“gp”时,POST 变量将使用相同的名字覆盖 GET 变量。任何 GPC 之外的字母都将被忽略。

prefix 参数做为变量名的前缀,置于全部被导入到全局做用域的变量以前。因此若是你有个名为“userid”的 GET 变量,同时提供了“pref_”做为前缀,那么你将得到一个名为 $pref_userid 的全局变量。

若是你对导入其它全局变量(例如 SERVER 变量)感兴趣,请考虑使用 extract()。

参考资料

allow_call_time_pass_reference

是否启用在函数调用时强制参数被按照引用传递。此方法已不被同意并在 PHP/Zend 将来的版本中极可能再也不支持。鼓励使用的方法是在函数定义中指定哪些参数应该用引用传递。鼓励你们尝试关闭此选项并确保脚本可以正常运行,以确保该脚本也能在将来的版本中运行(每次使用此特性都会收到一条警告,参数会被按值传递而不是按照引用传递)。

在函数调用时经过引用传递参数是不推荐的,由于它影响到了代码的整洁。若是函数的参数没有声明做为引用传递,函数能够经过未写入文档的方法修改其参数。要避免其反作用,最好仅在函数声明时指定那个参数须要经过引用传递。

参考资料

define_syslog_variables

初始化syslog相关的设置项,从这个版本进行了移除。

define_syslog_variables()只定义了全局变量。常数已经永远的定义,若是日志模块加载。你do not须要调用这个使用syslog常数。

也就是咱们若是想要使用syslog相关的参数,直接调用就行,不须要进行手动初始化。

参考资料

highlight.bg ini option.

Colors for Syntax Highlighting mode. Anything that’s acceptable in would work.

和这个高亮相关配置项还有下面几个,对代码高亮的颜色进行配置
- highlight.comment
- highlight.default
- highlight.html
- highlight.keyword
- highlight.string

参考资料

Session bug compatibility mode

php.ini中有说明
这是php4.3.0之后才有的安全设置。
出于安全的考虑php不建议你打开register_globals开关
但若关闭了register_globals(默认)时,session变量将不被自动转换成全局变量
此时传统的session变量注册方式session_register就失去意义了(session_register是把一个全局变量注册成session变量),由于访问session变量须要使用 SESSION _SESSION数组就能够了,而无须再用session_register注册了。以避免产生混乱

开关session.bug_compat_42 和 session.bug_compat_warn 就是为了检查此类状况而设置的

参考资料

session_is_registered(), session_register() and session_unregister() functions.

这里提到的三个session相关的函数

  • session_is_registered()
  • session_register()
  • session_unregister()

这些是session相关的注册相关的函数。

参考资料

y2k_compliance ini option.

这。。。是关于2000的时候的千年虫的配置项。

参考资料

magic_quotes_gpc

magic_quotes_gpc,magic_quotes_runtime和magic_quotes_sybase INI选项。get_magic_quotes_gpc,get_magic_quotes_runtime保存但始终返回false,set_magic_quotes_runtime引起e_core_error。

这个配置被撤销以后,若是再使用就会引起错误。

Removed support for putenv(“TZ=..”) for setting the timezone

再也不支持putenv(“TZ = ..”)设置时区,也就是不能再经过这个函数来设置时区相关的环境配置了.

添加 setting 到服务器环境变量。 环境变量仅存活于当前请求期间。 在请求结束时环境会恢复到初始状态。

设置特定的环境变量也有多是一个潜在的安全漏洞。 safe_mode_allowed_env_vars 包含了一个以逗号分隔的前缀列表。 在安全模式下,用户能够仅能修改用该指令设定的前缀名称的指令。 默认状况下,用户仅可以修改以 PHP_ 开头的环境变量(例如 PHP_FOO=BAR)。 注意:若是此指令是空的,PHP容许用户设定任意环境变量!

可见这个函数真是危险啊。。。

参考资料

Removed the timezone guessing algorithm in case the timezone isn’t set with date.timezone or date_default_timezone_set(). Instead of a guessed timezone, “UTC” is now used instead.

若是不设置时区与时区date.timezone或date_default_timezone_set()除去猜想算法。而不是猜想的时区,“UTC”如今是用来代替。

date_default_timezone_set() 设定用于全部日期时间函数的默认时区。

Note:
自 PHP 5.1.0 起(此版本日期时间函数被重写了),若是时区不合法则每一个对日期时间函数的调用都会产生一条 E_NOTICE 级别的错误信息,若是使用系统设定或 TZ 环境变量则还会产生 E_STRICT 级别的信息。

参考资料

Moved extensions to PECL 移动扩展PECL

原文

  • ext/sqlite. (Note: the ext/sqlite3 and ext/pdo_sqlite extensions are not affected)

翻译

  • EXT / SQLite。(注:EXT / sqlite3和EXT / pdo_sqlite扩展不受影响)

ext/sqlite

This package is not maintained anymore and has been superseded. Package has moved to channel http://php.net/sqlite, package .
这个包是否是保持了与已被取代。包已经转移到渠道http://php.net/sqlite,包。

也就是说这个sqlite从pecl转移到了SQLite的扩展中。

参考资料

General improvements 通常的改进

原文

  • Added short array syntax support ([1,2,3]), see UPGRADING guide for full details.
  • Added binary numbers format (0b001010).
  • Added support for Class::{expr}() syntax.
  • Added multibyte support by default. Previously php had to be compiled with –enable-zend– multibyte. Now it can be enabled or disabled through zend.multibyte directive in php.ini.
  • Removed compile time dependency from ext/mbstring.
  • Added support for Traits.
  • Added closure $this support back.
  • Added array dereferencing support.
  • Added callable typehint.
  • Added indirect method call through array. #47160.
  • Added DTrace support.
  • Added class member access on instantiation (e.g. (new foo)->bar()) support.
  • <?=is now always available regardless of the short_open_tag setting.
  • Implemented Zend Signal Handling (configurable option –enable-zend-signals, off by default).
  • Improved output layer, see README.NEW-OUTPUT-API for internals.
  • lmproved unix build system to allow building multiple PHP binary SAPIs and one SAPI module the same time. #53271, #52419.
  • Implemented closure rebinding as parameter to bindTo.
  • Improved the warning message of incompatible arguments.
  • Improved ternary operator performance when returning arrays.
  • Changed error handlers to only generate docref links when the docref_root INI setting is not empty.
  • Changed silent conversion of array to string to produce a notice.
  • Changed default value of “default_charset” php.ini option from ISO-8859-1 to UTF-8.
  • Changed silent casting of null/”/false into an Object when adding a property into a warning.
  • Changed E_ALL to include E_STRICT.
  • Disabled windows CRT warning by default, can be enabled again using the ini directive windows_show_crt_warnings.
  • Fixed bug #55378: Binary number literal returns float number though its value is small enough.

翻译

  • 添加短数组语法支持([1,2,3]),详情见升级指南。
  • 添加二进制格式(0b001010)。
  • 增长支持类::{ }()表达式的语法。
  • 添加多字节默认支持。之前的PHP必须编译——使Zend字节。如今能够启用或禁用经过zend.multibyte指令在php.ini。
  • 从EXT / mbstring编译时依赖。
  • 增长支持的特征。
  • 添加关闭美圆的支持。
  • 添加数组引用的支持。
  • 添加可赎回typehint。
  • 增长间接方法调用经过阵列。# 47160。
  • 加入DTrace支持。
  • 添加类成员访问实例(例如(新富)-> bar())支持。
  • <?=永远是如今可用的short_open_tag设置。
  • 实现Zend信号处理(可配置的选项——启用Zend信号,默认关闭)。
  • 改进的输出层,看到readme.new-output-api内部。
  • 改进的UNIX系统容许创建建设多个PHP二进制SAPIs和SAPI模块相同的时间。# 53271,# 52419。
  • 实施关闭绑定参数的结合。
  • 改进的相互矛盾的警告信息。
  • 三元运算符返回时阵列性能改进。
  • 改变错误处理程序只产生docref连接时,docref_root ini设置不空。
  • 改变数组字符串生成通知无声的转换。
  • 改变默认值“default_charset”的选项从ISO-8859-1为UTF-8。
  • 改变沉默铸造空/”/假为对象添加属性到一个警告。
  • 改变e_all包括e_strict。
  • 禁用Windows CRT警告默认状况下,能够再次启用使用INI指令windows_show_crt_warnings。
  • 固定的错误# 55378:二进制数的文本返回浮点数的值足够小,虽然。

发现这么翻译还不如不翻译看的明白。。。。

short array syntax support 短数组支持

<?php $array = array( "foo" => "bar", "bar" => "foo", ); // 自 PHP 5.4 起 $array = [ "foo" => "bar", "bar" => "foo", ]; ?>

参考资料

binary numbers format 二进制直接量

从PHP5.4开始, 咱们能够直接在代码中书写二进制直接量了. 这个在定义一些标志位的时候, 尤其方便.

$bin  = 0b1101;
echo $bin;

//13

参考资料

support for Class::{expr}() syntax

Makes PHP more flexible, when calling class/object methods.

$method = 'method';

$test = new Test();

$test->method();
$test->$method();
$test->{'method'}();

Test::method();
Test::$method();
Test::{'method'}();

参考资料

multibyte support 多字节支持

添加多字节默认支持。之前的PHP必须编译——使Zend字节。如今能够启用或禁用经过zend.multibyte指令在php.ini。

参考资料

Removed compile time dependency from ext/mbstring

从EXT / mbstring编译时依赖

Added support for Traits

自 PHP 5.4.0 起,PHP 实现了代码复用的一个方法,称为 traits。

Traits 是一种为相似 PHP 的单继承语言而准备的代码复用机制。Trait 为了减小单继承语言的限制,使开发人员可以自由地在不一样层次结构内独立的类中复用方法集。Traits 和类组合的语义是定义了一种方式来减小复杂性,避免传统多继承和混入类(Mixin)相关的典型问题。

Trait 和一个类类似,但仅仅旨在用细粒度和一致的方式来组合功能。Trait 不能经过它自身来实例化。它为传统继承增长了水平特性的组合;也就是说,应用类的成员不须要继承

参考资料

Added closure $this support back

用于表明 匿名函数 的类.

匿名函数(在 PHP 5.3 中被引入)会产生这个类型的对象。在过去,这个类被认为是一个实现细节,但如今能够依赖它作一些事情。自 PHP 5.4 起,这个类带有一些方法,容许在匿名函数建立后对其进行更多的控制。

除了此处列出的方法,还有一个 __invoke 方法。这是为了与其余实现了 __invoke()魔术方法 的对象保持一致性,但调用匿名函数的过程与它无关。

待续。。

参考资料

Added array dereferencing support

能够说上是直接获取数组中的元素吧,对于咱们来讲仍是很方便的,能省下一个变量。

在之前, 咱们若是定义一个返回数组的函数:

<?php function foo() { return array(1, 2, 3); }

那么, 若是我要获取返回数组中的第二个元素, 就只能:

<?php list(, $mid, ) = foo(); //或者: $tmp = $foo(); $mid = $tmp[1];

而从5.4开始, 咱们就不须要这么麻烦了, 只须要:

<?php $mid = foo()[1];

另外, 也可使用引用:

<?php function &getTable() { return $GLOBALS; } getTable()["foo"] = "laruence"; echo $foo; //laruence

参考资料

函数类型提示(Callable typehint)

要想了解这个首先须要了解的是类型约束

PHP 5 可使用类型约束。函数的参数能够指定必须为对象(在函数原型里面指定类的名字),接口,数组(PHP 5.1 起)或者 callable(PHP 5.4 起)。不过若是使用 NULL 做为参数的默认值,那么在调用函数的时候依然可使用 NULL 做为实参。

若是一个类或接口指定了类型约束,则其全部的子类或实现也都如此。

类型约束不能用于标量类型如 int 或 string。Traits 也不容许

/** * 测试函数 * 第一个参数必须为 OtherClass 类的一个对象 */
    public function test(OtherClass $otherclass) {
        echo $otherclass->var;
    }

其中的OtherClass 就是咱们的类型约束

在PHP5.4版本中,新增了Callable类型的类型约束

<?php function foo(callable $callback) { }
<?php
foo("false"); //Catchable fatal error: Argument 1 passed to foo() must be callable *
foo("printf"); //okey
foo(function(){}); //okey

class A {
    static function show() {
    }
}

foo(array("A", "show")); //okey

参考资料

indirect method call through array 经过间接方法调用的数组

这里在后面还有一个#47160的bug.

<?php
// For 5.2.x as well.
class Thing {
    static function DoesStuff() {
        echo 'Hello, World';
    }
}

$f = array('Thing', 'DoesStuff');

$f();

//返回 Hello, World
?>

按照bug页面上的,以前的版本就会返回错误,如今已经好啦~

<?php


class Hello {
    //这是一个静态的方法
   static public function world($x) {
     echo "Hello, $x\n";
   }
}


function hello_world($x) {
   echo "Hello, $x\n";
}

 //数组中包含了三个,第一个数组,第二个匿名函数,第三个字符串
$callbacks = array(
   array('Hello', 'world'),
   function ($x) { echo "Hello, $x\n"; },
   'hello_world'
);

 //循环了数组
foreach ($callbacks as $k => $callback) {
   if (is_callable($callback)) { //检测参数是否为合法的可调用结构
     $callback($k);  //而后就把本身的key值做为参数传递过去了 
   }
}


//RESULT:
//Hello, 0 指向了Hello的world静态方法
//Hello, 1 参数自己就是匿名函数,是能够直接执行的
//Hello, 2 做为字符串的参数能够找到相同名字的方法,因此执行了


//CalvinLee
?>

上面的第一个栗子说明了咱们能够经过数组的形式直接调用方法,确认回调函数,经过array('类','方法')的方式进行直接调用。

这是一个由于bug形成的新特性。

参考资料

DTrace 支持

DTrace(全称Dynamic Tracing),也称为动态跟踪,是由 Sun™ 开发的一个用来在生产和试验性生产系统上找出系统瓶颈的工具,能够对内核(kernel)和用户应用程序(user application)进行动态跟踪而且对系统运行不构成任何危险的技术。在任何状况下它都不是一个调试工具, 而是一个实时系统分析寻找出性能及其余问题的工具。

也就是这个调试工具能够直接支持PHP辣!能够进行更深层次的代码调试。

有时间能够研究一下这个怎么用。

。。。

参考资料

在实例化类成员的访问支持

class Test {
    public function foo() {
        return $this;
    }

    public function bar() {
        return 'oh hai';
    }
}

$t = (new Test)->foo();

print $t->bar();

咱们能够直接调用啦啦啦~

很方便的样子!

参考资料

<?= 短标签

PHP5.4里默认开启了短标签设置,支持了行内的短标签 <?= ?>

<?php
$a = 2;
?>
<?=$a?>

这个短标签直接输出了,因此是用于行内的。

参考资料

Zend Signal Handling

实现Zend Signal Handling(可配置的选项——–enable-zend-signals,默认关闭)

新的机制, 叫作zend signal, 它的理念, 来自Yahoo的”延迟信号处理”(Yahoo signal deferring mechanism), 然后, facebook把这套理念加入了PHP中, 为了提高PHP+Apache 1.X下PHP调用ap_block/ap_unblock的性能

参考资料

Improved output layer, see README.NEW-OUTPUT-API for internals

改进的输出层,看到readme.new-output-api内部

看起来像是内核的输出层改动,可是实在是找不到资料,不知道怎么理解这一条。QAQ

multiple PHP binary SAPIs and one SAPI module 多个PHP二进制SAPIs和SAPI模块

改进的UNIX系统容许创建建设多个PHP二进制SAPIs和SAPI模块相同的时间。#53271, #52419.

这里在后面提到了两个bug。

Using configure options –enable-cgi and –enable-fpm together will not produce the php-cgi binary.

两个配置一块儿的时候就不会产生php-cgi的二进制。
两个模块做为配置项的时候会编译失败。

参考资料

Implemented closure rebinding as parameter to bindTo 实施关闭从新绑定的参数结合

Closure::bind — 复制一个闭包,绑定指定的$this对象和类做用域。
Closures: Object extension 关闭对象扩展

这里须要理解一个Closure的概念,Closure 类,匿名函数类。

匿名函数(在 PHP 5.3 中被引入)会产生这个类型的对象。在过去,这个类被认为是一个实现细节,但如今能够依赖它作一些事情。自 PHP 5.4 起,这个类带有一些方法,容许在匿名函数建立后对其进行更多的控制

<?php

class APP {

    public $var = 25;

    public function __construct() {

    }

    public function get($callback) {
        if (!is_callable($callback)) {
            throw new InvalidArgumentException('Paran must be callable.');
        }
        // $callback->bindTo($this);
// $callback->bindTo($this, $this); 
// $callback();
        //上面的回调方法找不到绑定的对象,下面的方法是用一个新的变量来作绑定函数的结果,而后执行
        $callback1 = $callback->bindTo($this, $this);
        $callback1();
    }

}

$app = new APP();
$app->get(function() use ($app) {//做为本身的匿名函数
    echo '<pre>';
    var_dump($app);
    echo '<br />';
    var_dump($this);
});
?>

参考资料

Improved the warning message of incompatible arguments 改进的不兼容的参数的警告信息

就是字面上的意思。。。

Improved ternary operator performance when returning arrays 三元运算符返回时数组性能改进

优化了数组的时候的性能,当返回值是array的时候速度获得了提高。

参考资料
- http://www.laruence.com/2011/11/04/2258.html
- http://grokbase.com/t/php/php-internals/11aeyhp2ek/ternary-operator-performance-improvements
- http://php.net/manual/en/language.operators.comparison.php

Changed error handlers 改变错误处理程序只产生docref连接时,docref_root ini设置不空

当配置文件 php.ini 中的 docref_root 的值为空的时候,更改了 docref links 指向的连接。

也就是对默认的指向的错误提醒的页面链接进行了修改.

修改默认值不属于很重要的功能,对于这种更新对项目来讲不是特别的重要。

新的错误信息格式包含了对应的参考页面,该页面对错误进行具体描述,或者描述了致使该错误发生的函数。为了提供手册的页面,你能够在PHP官方站点下载对应语言的手册,并在ini中设置网址到本地对应的地址。若是你的本地手册拷贝可使用”/manual/” 访问,你就能够简单的设置 docref_root=/manual/。另外你还须要设置 docref_ext 匹配你本地文件的后缀名 docref_ext=.html。固然也能够设置一个外部的参考地址。例如你能够设置 docref_root=http://manual/en/ 或者 docref_root=”http://landonize.it/?how=url&theme=classic&filter=Landon &url=http%3A%2F%2Fwww.php.net%2F”

一般须要在 docref_root 后面以 “/”结尾, 可是在以上的第二种示例状况中没必要这么设置。

Note:

由于这么作能够快速定位和查看到函数的说明,因此它对你的开发会很是有用。建议永远不要再生产系统中使用 (例如系统被链接到互联网对外提供服务)。

参考资料

Changed silent conversion of array to string to produce a notice 改变了数组转换字符串的提醒

木有看明白。。。。

参考资料

Changed default value of “default_charset” php.ini option from ISO-8859-1 to UTF-8 改变默认值“default_charset”的选项从ISO-8859-1为UTF-8

默认设置是UTF-8.

PHP always outputs a character encoding by default in the Content-type: header. To disable sending of the charset, simply set it to be empty.

有趣的是此次发现了国内的工程师的提交的bug~

参考资料

Changed silent casting of null/”/false into an Object when adding a property into a warning 当一个对象中有空的属性时加入了一个警告

当给一个对象加入一个属性的时候,扔掉null或者false会返回一个警告

Changed E_ALL to include E_STRICT E_ALL中包括了E_STRICT

参考资料

Disabled windows CRT warning by default, can be enabled again using the ini directive windows_show_crt_warnings 禁用Windows CRT警告默认状况下,能够再次启用使用INI指令windows_show_crt_warnings

windows CRT

Visual Studio 2012 更新 1 支持的 Windows 8,Windows Server 2012,Windows 7,Windows Server 2008中,Windows Vista,Windows XP Service Pack 3 (SP3) C 运行库,x86 的 Windows XP Service Pack 2 (SP2) x64 和 Windows Server 2003 Service Pack 2 (SP2) x86 和 x64 的。 全部这些操做系统支持 Windows 应用程序编程接口 (API) (API) 提供和 Unicode 支持。 此外,全部 Win32 应用程序中使用多字节字符集 (MBCS)。

This directive shows the Windows CRT warnings when enabled. These warnings were displayed by default until PHP 5.4.0.

This directive shows the Windows CRT warnings when enabled. These warnings were displayed by default until PHP 5.4.0.

参考资料

Fixed bug #55378: Binary number literal returns float number though its value is small enough 固定的错误# 55378:二进制数的文本返回浮点数虽然其值足够小

上面提到过这个版本支持了直接的二进制的输出,因此这条就是修复返回二进制转换的浮点数的错误。

Test script: ---------------
<?php
var_dump(0b1111111); var_dump(0b1111111111111111);


Expected result: ----------------
int(127)
int(65535)

Actual result: --------------
int(127)
float(65535)

参考资料

Improved Zend Engine memory usage 改进的内存使用Zend引擎

原文

  • Improved parse error messages.
  • Replaced zend_function.pass_rest_by_reference by ZEND_ACC_PASS_REST_BY_REFERENCE in zend_function.fn_flags.
  • Replaced zend_function.return_reference by ZEND_ACC_RETURN_REFERENCE in zend_function.fn_flags.
  • Removed zend_arg_info.required_num_args as it was only needed for internal functions. Now the first arg_info for internal functions (which has special meaning) is represented by zend_internal_function_info structure.
  • Moved zend_op_array.size, size_var, size_literal, current_brk_cont, backpatch_count into CG(context) as they are used only during compilation.
  • Moved zend_op_array.start_op into EG(start_op) as it’s used only for ‘interactive’ execution of single top-level op-array.
  • Replaced zend_op_array.done_pass_two by ZEND_ACC_DONE_PASS_TWO in zend_op_array.fn_flags.
    op_array.vars array is trimmed (reallocated) during pass_two.
  • Replaced zend_class_entry.constants_updated by ZEND_ACC_CONSTANTS_UPDATED in zend_class_entry.ce_flags.
  • Reduced the size of zend_class_entry by sharing the same memory space by different information for internal and user classes. See zend_class_entry.info union.
  • Reduced size of temp_variable.

翻译

  • 改进的解析错误消息。

  • 经过更换zend_function.pass_rest_by_reference zend_acc_pass_rest_by_reference在zend_function.fn_flags。

  • 经过更换zend_function.return_reference zend_acc_return_reference在zend_function.fn_flags。

  • 删除zend_arg_info.required_num_args由于这只是内部功能的须要。如今内部功能的第一arg_info(具备特殊意义的zend_internal_function_info结构表示)。

  • 移动zend_op_array.size,size_var,size_literal,current_brk_cont,backpatch_count为CG(上下文)做为他们在编译过程当中只使用。

  • 移动zend_op_array.start_op成如(start_op)它只用于“单顶级运算阵列交互执行。

  • 经过更换zend_op_array.done_pass_two zend_acc_done_pass_two在zend_op_array.fn_flags。

  • op_array.vars阵列在pass_two修剪(从新分配)。

  • 经过更换zend_class_entry.constants_updated zend_acc_constants_updated在zend_class_entry.ce_flags。

  • 减小zend_class_entry大小由内部和用户类不一样信息共享相同的内存空间。看到zend_class_entry.info联盟。

  • temp_variable缩小。

这部分的说明是关于zend引擎相关的,按目前个人水平还不是能很明白的理解这些的含义。

Improved Zend Engine, performance tweaks and optimizations 改进的Zend引擎,性能调整和优化

原文

  • Inlined most probable code-paths for arithmetic operations directly into executor.
  • Eliminated unnecessary iterations during request startup/shutdown.
  • Changed $GLOBALS into a JIT autoglobal, so it’s initialized only if used. (this may affect opcode caches!)
  • Improved performance of @ (silence) operator.
  • Simplified string offset reading. $str[1][0] is now a legal construct.
  • Added caches to eliminate repeatable run-time bindings of functions, classes, constants, methods and properties.
  • Added concept of interned strings. All strings constants known at compile time are allocated in a single copy and never changed.
  • ZEND_RECV now always has IS_CV as its result.
  • ZEND_CATCH has to be used only with constant class names.
  • ZEND_FETCH_DIM_? may fetch array and dimension operands in different order.
  • Simplified ZEND_FETCH_*_Roperations. They can’t be used with the EXT_TYPE_UNUSEDflag any more. This is a very rare and useless case. ZEND_FREE might be required after them instead.
  • Split ZEND_RETURN into two new instructions ZEND_RETURN and ZEND_RETURN_BY_REF.
  • Optimized access to global constants using values with pre-calculated hash_values from the literals table.
  • Optimized access to static properties using executor specialization. A constant class name may be used as a direct operand of ZEND_FETCH_* instruction without previous ZEND_FETCH_CLASS.
  • zend_stack and zend_ptr_stack allocation is delayed until actual usage.

翻译

  • 内联最可能的代码路径,直接进入执行算术运算。

  • 消除没必要要的迭代请求启动/关机时。

  • 改变成一个JIT autoglobal =美圆,因此它的初始化,若是使用。(这可能会影响操做码缓存!)

  • 改进的性能”(沉默)算子。

  • 简化的字符串偏移阅读。$str [ 1 ] [ 0 ]如今的法律构建。

  • 消除重复的运行时绑定的功能,添加缓存类,常量,方法和属性。

  • 拘留字符串添加的概念。全部字符串常量在编译时被分配在一个单拷贝,永远都不会改变的。

  • zend_recv如今老是is_cv做为结果。

  • zend_catch如今只须要进行不断的类名称。

  • zend_fetch_dim_?能够把不一样排列和尺寸数。

  • 简化zend_fetch_ * _r操做。他们不能用任何ext_type_unused旗。这是一个很是可贵的和无用的状况下。- zend_free可能在他们的要求。

  • zend_return分裂为两个新的指令zend_return和zend_return_by_ref。

  • 优化访问全局常量使用的值与预先计算的hash_values从文字表。

  • 优化访问静态属性用遗嘱执行人专业化。一个恒定的类的名称能够做为直接操做数指令没有之前的zend_fetch_class zend_fetch_ *。

  • zend_stack和zend_ptr_stack分配延迟到实际使用。

  • 改进的Zend引擎,性能调整和优化

机翻好渣。。。。。等我长发及腰,再来看这个可好QAQ

Other improvements to Zend Engine 在Zend引擎改进

原文

  • Added an optimization which saves memory and emalloc/efree calls for empty HashTables.
  • Added ability to reset user opcode handlers.
  • Changed the structure of op_array.opcodes. The constant values are moved from opcode operands into a separate literal table.
  • Fixed (disabled) inline-caching for ZEND_OVERLOADED_FUNCTION methods.
  • Fixed bug #43200 (Interface implementation / inheritence not possible in abstract classes).

    翻译

  • 增长了一个优化,节省内存和emalloc /饱和须要空表。

  • 新增能力重置用户操做处理程序。

  • 改变了op_array.opcodes结构。该常数的值是从操做码操做数为一个单独的文字表。

  • 固定(禁用)为zend_overloaded_function方法内联缓存。

  • 固定的错误# 43200(接口的实现/继承抽象类不可能)。

PHP结构

zend引擎做为底层,仍是须要我理解更深刻再去看啦~

后记

关于PHP

PHP做为流行的脚本语言,上手很是快,可是这并不表明这个一个糟糕的语言,从这个版本的更新记录,我也看到了每次的改进,以及社区内你们的努力。

此次作ChangeLog的整理大概会写三个文章共六篇,因为这个Log实在是太长了仍是写一半先发出去比较好~

引用的资料在每一个小结后面都有,方便本身和你们查阅。

若是发现描述错误,请务必评论或者私信我,若是有错,发现了就不能再错下去~

关于整理资料

咱们依靠网络,天天在接触着不少的新闻和资料,对咱们来说,从这些里面找出有用的知识并吸取仍是有必定难度的,特别是国内糟糕的博客环境,一个文章发布出来以后会有好多网站抄袭抓取,内容还不全,对于初学者会形成负面影响,且珍惜。

关于我的成长

当有一个大目标的时候,才能够转化成小目标进行执行。 执行力永远放在第一位。