PHP 5.4 overview

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.


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().

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 Comment

Your email address will not be published. Required fields are marked *