PHP 5.4 release is announced on March 1 officially which is a major release in 5.x series. PHP 5.4 has major new features summarized below.
1) Built in Web Server: Started from PHP 5.4, PHP has its own built in web server for testing purpose. This way PHP will have no need for any other web server like Apache or IIS. This web server is only for development and testing purpose and should be not used for production. Currently this web server is only available in CLI (Command Line Interface) mode. It is not a complete sophisticated web server like others, but in PHP, it is a good addition.
2) Shorted Array Syntax: In PHP 5.4, some new syntax features are added and one of them is short arrays syntax. Currently an array is initialized as below
$testArray = array(1, 2, 3, 4, 5);
$otherArray = array (‘name’ => ‘Altaf Hussain’, ‘education’ => ‘Software Engineer’, ‘Job’ => ‘PHP Developer’);
with the new syntax, an array can be initialized as below
$testArray = [ 1, 2, 3, 4, 5 ];
$otherArray = [ ‘name’ => ‘Altaf Hussain’, ‘education’ => ‘Software Engineer’, ‘Job’ => ‘PHP Developer’ ];
3) Traits: As of PHP 5.4, a new important feature called Traits is added. Traits are used for code used for code reuse in languages which has no support for multiple inheritance like PHP. Traits are almost like classes but it can only have properties and methods or functions. Traits itself cant be instantiated, but can be used in PHP classes. With Traits new keywords are also defined in PHP like insteadof. For further details about Traits please read this . Traits are very interesting and I like this feature myself.
4) Removed Features: In PHP 5.4, some features are removed including Safe Mode and all its related ini options,register_globals and register_long_arrays ini options and some other ini options and other features are being removed.
5) Other New Features: Below PHP 5.4 versions PHP has ISO-8859-1 as a default character set defined in ini file but now it is changed to UTF-8, and hence from PHP 5.4, default character set will be UTF-8. Another new features added is Binary number format. Some other new features added are short open tag ( <?= ) is now always available without enabling it in php.ini, changed E_ALL to has E_STRICT for error messages, new syntax features, class member access on instantiation like $obj = new (CLassName)->memberFunction(); and hex2bin() function which converts hexadecimal number to binary and so on.
6) Other Improvements: Other improvements in PHP 5.4 includes Zend Engine Optimization, Zend memory usage optimization, improved core functions, improved differeng SAPIs like APACHE SAPI, CLI SAPI and CGI / FAST CGI SAPI, improved BCmath, CURL, DATE, DBA, HASH, MSSQL, MYSQL, SESSION and other extensions and so on.
PHP 5.4 has much more improvements and new features, and due to that features I like PHP 5.4 the most.