您的位置:首页 > 编程语言 > PHP开发

【PHP】PHP5.4.0版本号ChangeLog具体解释(上)

2016-01-17 15:41 746 查看

前言

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

之前好久就想写这种一片文章,来说明下各个版本号的差异。这次算是拿出时间了。

这次的是第一篇,眼下规划写三篇

PHP5.4.0

PHP5.5.0

PHP5.6.0

一方面是对自己的知识的整理,一方面是对自己的一次提升。

官方说明

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

具体说明

01 Mar 2012

原文



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 +是理想的配置,否则有可能是不对的。



autoconf

php编译安装的时候须要的依赖软件。所以新版本号相应配套的软件也要换成最新的对性能来讲才保险啊~

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.



參考资料

http://stackoverflow.com/questions/6517401/what-is-the-break-continue-var-syntax-will-be-removed-in-php-5-4

http://php.net/control-structures.break

Safe mode and all related ini options. 去除安全模式以及在配置文件的选项

PHP 的安全模式是为了试图解决共享服务器(shared-server)安全问题而设立的。

在结构上,试图在 PHP 层上解决问题是不合理的,但改动 web 服务器层和操作系统层显得非常不现实。因此很多人,特别是 ISP。眼下使用安全模式。

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

保安措施和安全模式,也就是移除了php.ini中全部safe_mode相关的配置项

被安全模式限制或屏蔽的函数 。

在安全限制模式下,有些函数不能被使用。

这个限制也将被移除

參考资料

http://php.net/manual/zh/features.safe-mode.php

register_globals and register_long_arrays ini options.

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

參考资料

http://php.net/manual/zh/ini.core.php#ini.register-globals

import_request_variables()


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

bool import_request_variables ( string types[,stringtypes [, 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()。

參考资料

http://php.net/manual/zh/function.import-request-variables.php

allow_call_time_pass_reference


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

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



參考资料

http://php.net/manual/zh/ini.core.php#ini.allow-call-time-pass-reference

/article/2861104.html

define_syslog_variables

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


define_syslog_variables()仅仅定义了全局变量。

常数已经永远的定义,假设日志模块载入。你do not须要调用这个使用syslog常数。



也就是我们假设想要使用syslog相关的參数。直接调用即可,不须要进行手动初始化。

參考资料

http://cn2.php.net/manual/zh/function.define-syslog-variables.php

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

參考资料

http://php.net/manual/en/misc.configuration.php#ini.syntax-highlighting

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数组就能够了,而无须再用session_register注冊了。

以免产生混乱

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



參考资料

http://bbs.csdn.net/topics/40340235

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

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

session_is_registered()

session_register()

session_unregister()

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

參考资料

http://php.net/manual/en/function.session-is-registered.php

http://php.net/manual/en/function.session-register.php

http://php.net/manual/en/function.session-unregister.php

y2k_compliance ini option.

这。。



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

參考资料

http://www.bkjia.com/PHPjc/852740.html

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同意用户设定随意环境变量!



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

。。

參考资料

http://php.net/manual/zh/function.putenv.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 级别的信息。



參考资料

http://php.net/manual/zh/function.date-default-timezone-set.php

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的扩展中。

參考资料

http://pecl.php.net/package/SQLite

http://php.net/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",
];
?>


參考资料

http://cn.php.net/manual/zh/language.types.array.php

binary numbers format 二进制直接量

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

$bin  = 0b1101;
echo $bin;

//13


參考资料

http://www.laruence.com/2011/10/10/2232.html

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'}();


參考资料

http://yogurt.iteye.com/blog/1447483

multibyte support 多字节支持

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

參考资料

http://www.laruence.com/2011/11/18/2305.html

http://serverfault.com/questions/145413/php-what-is-enable-zend-multibyte-configure-option-for

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 不能通过它自身来实例化。它为传统继承添加了水平特性的组合;也就是说。应用类的成员不须要继承



參考资料

http://php.net/manual/zh/language.oop5.traits.php

Added closure
$this
support back


用于代表 匿名函数 的类.

匿名函数(在 PHP 5.3 中被引入)会产生这个类型的对象。

在过去,这个类被觉得是一个实现细节,但如今能够依赖它做一些事情。

自 PHP 5.4 起。这个类带有一些方法,同意在匿名函数创建后对其进行很多其它的控制。

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



待续。。

參考资料

http://php.net/manual/zh/class.closure.php

http://stackoverflow.com/questions/5734011/php-5-4-closure-this-support

https://eval.in/private/f2fb0986b99669

https://wiki.php.net/rfc/closures

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


參考资料

http://www.laruence.com/2011/10/10/2212.html

函数类型提示(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


參考资料

http://www.laruence.com/2011/10/10/2229.html

http://www.laruence.com/2011/07/02/2102.html

http://php.net/manual/zh/language.oop5.typehinting.php

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造成的新特性。

參考资料

https://bugs.php.net/bug.php?id=47160

https://wiki.php.net/rfc/indirect-method-call-by-array-var

http://php.net/manual/zh/function.is-callable.php

DTrace 支持


DTrace(全称Dynamic Tracing),也称为动态跟踪。是由 Sun™ 开发的一个用来在生产和试验性生产系统上找出系统瓶颈的工具,能够对内核(kernel)和用户应用程序(user application)进行动态跟踪而且对系统运行不构成不论什么危急的技术。

在不论什么情况下它都不是一个调试工具。 而是一个实时系统分析寻找出性能及其它问题的工具。



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

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



。。

參考资料

https://blogs.oracle.com/shanti/entry/dtrace_support_for_php

http://php.net/manual/zh/features.dtrace.dtrace.php

http://baike.baidu.com/view/3223769.htm

http://blog.experimentalworks.net/2010/04/php-5-3-99-dev-and-dtrace-part-i/

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

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

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

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

print $t->bar();


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

非常方便的样子。

參考资料

http://stackoverflow.com/questions/9551251/php-class-member-access-on-instantiation

<?=
短标签

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


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


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

參考资料

http://php.net/manual/zh/language.basic-syntax.phptags.php

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的性能



參考资料

http://www.laruence.com/2011/10/19/2247.html

http://www.laruence.com/2008/12/31/647.html

http://www.laruence.com/2011/01/27/1854.html

https://wiki.php.net/rfc/zendsignals

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的二进制。

两个模块作为配置项的时候会编译失败。

參考资料

https://bugs.php.net/bug.php?id=53271

https://bugs.php.net/bug.php?id=52419

http://php.net/manual/en/install.pecl.php-config.php

http://blog.sina.com.cn/s/blog_7cc2d3440100v6mf.html

http://php.find-info.ru/php/016/ch23lev1sec1.html

http://www.cnblogs.com/zl0372/articles/php_17.html

http://www.laruence.com/2008/08/12/180.html

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);
});
?

>


參考资料

/article/1801936.html

http://php.net/manual/zh/closure.bindto.php

http://php.net/manual/zh/closure.bind.php

https://wiki.php.net/rfc/closures

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:

由于这么做能够高速定位和查看到函数的说明,所以它对你的开发会非常实用。

建议永远不要再生产系统中使用 (比如系统被连接到互联网对外提供服务)。



參考资料

http://php.net/manual/zh/errorfunc.configuration.php#ini.docref-root

http://php.net/manual/en/function.main.php

https://perishablepress.com/advanced-php-error-handling-via-htaccess/

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

木有看明确。

。。。

參考资料

http://stackoverflow.com/questions/3389582/notice-array-to-string-conversion-why

http://stackoverflow.com/questions/20117856/php-array-to-string-as-parameters

http://stackoverflow.com/questions/7244564/notice-array-to-string-conversion

http://grokbase.com/t/php/php-bugs/11b2a951bt/php-bug-bug-60198-new-array-to-string-notice-from-array-functions

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.



有趣的是这次发现了国内的project师的提交的bug~

參考资料

https://bugs.php.net/bug.php?id=61354

http://grokbase.com/t/php/php-internals/123cfv42tq/default-charset-confusion

http://news.php.net/php.internals/58853

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

參考资料

http://www.zhuwenbo.net/?p=146

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.



參考资料

http://blog.csdn.net/wwl33695/article/details/8472291

http://cn.php.net/manual/zh/ini.core.php#ini.windows-show-crt-warning

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)


參考资料

https://bugs.php.net/bug.php?id=55378

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_*_R
operations. They can’t be used with the
EXT_TYPE_UNUSED
flag 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(接口的实现/继承抽象类不可能)。



zend引擎作为底层。还是须要我理解更深入再去看啦~

后记

关于PHP

PHP作为流行的脚本语言,上手非常快,可是这并不代表这个一个糟糕的语言,从这个版本号的更新记录。我也看到了每次的改进。以及社区内大家的努力。

这次做ChangeLog的整理大概会写三个文章共六篇,由于这个Log实在是太长了还是写一半先发出去比較好~

引用的资料在每一个小结后面都有。方便自己和大家查阅。

假设发现描写叙述错误。请务必评论或者私信我,假设有错,发现了就不能再错下去~

关于整理资料

我们依靠网络。每天在接触着非常多的新闻和资料。对我们来讲,从这些里面找出实用的知识并吸收还是有一定难度的,特别是国内糟糕的博客环境。一个文章公布出来之后会有好多站点抄袭抓取。内容还不全。对于刚開始学习的人会造成负面影响,且珍惜。

关于个人成长

当有一个大目标的时候,才干够转化成小目标进行运行。

运行力永远放在第一位。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: