php5.4新增特性

php5.4已经出来了,我们网站马上跟进,升级之后,除了一些老的代码函数不能兼容以外,可以说升级的很成功,服务器cpu和内存占有率都有所下降,性能有提高。下面是官方介绍新版特性:
PHP 5.4.0 offers a wide range of new features:
1,Support for traits has been added.
traits是用来解决php不能多重继承的问题,个人觉得暂时用不着
2.Short array syntax has been added, e.g.
[php]
$a = [1, 2, 3, 4];
$a = [‘one’ => 1, ‘two’ => 2, ‘three’ => 3, ‘four’ => 4];
[/php]
定义数组用‘[]’代替‘array’,这样定义数组更简单了,这个特性最实用
 
3.Function array dereferencing has been added, e.g.
[php]foo()[0][/php]
函数后面也可以数组索引
 
4.Closures now support $this.
匿名函数中,可以使用$this
5.<?= is now always available, regardless of the short_open_tag php.ini option.
默认已经支持短标签
6.Class member access on instantiation has been added, e.g.
[php](new Foo)->bar()[/php]
实例化类的时候可以访问到类成员
 
7.Class::{expr}() syntax is now supported.
8.Binary number format has been added, e.g. 0b001001101.
9.Improved parse error messages and improved incompatible arguments warnings.
10.The session extension can now track the upload progress of files.
11.Built-in development web server in CLI mode.

发表评论

邮箱地址不会被公开。 必填项已用*标注