PHP 5.4 overview

By

July 17, 2012GeneralNo comments

1. Traits feature is added. Traits is used to reduce the limitations of single inheritance. A Trait cannot be instantiated on its own. Traits allows its methods to be reused in several independent classes.

Example:

In the above example code we define a trait using the keyword trait followed by its definition.
We can use the methods of trait by adding this statementuse traitname in any class.

2. Short open tag is available now regardless of php.ini setting

3. Short array syntax has been added, e.g. $a = [1, 2, 3, 4]; or $a = [‘one’ => 1, ‘two’ => 2, ‘three’ => 3, ‘four’ => 4];.

4. Class member access on instantiation has been added, e.g. (new Foo)->bar().

5.
Class::{expr}() syntax is now supported.

6. Binary number format has been added, e.g. 0b001001101.

7. Improved parse error messages and improved incompatible arguments warnings.

8. The session extension can now track the upload progress of files.

Leave a Reply