So the other day, Rasmus tweeted that PHP 5.4 was fully released (following several release candidates):
PHP 5.4.0 is out – go get it #php
— Rasmus Lerdorf (@rasmus) March 1, 2012
There are some great additions, the highlights (other than a huge increase in speed, apparently) being square bracket notation for arrays, array dereferencing and the ability to use traits.
I’m quite excited (sadly) about the use of square brackets to initialise an array, and to be able to code up their contents in this way:
This is similar to the way we do lists in Python.
Array dereferencing means we can now access particular elements within an array upon creating it:
This works the same way with Objects:
There’s now something called Traits, which is a concept brought in to PHP 5.4:
This allows a trait to be reused by any objects which refer to it in this way. It’s to save on copy and pasting blocks of code. The compiler now does that for us!
Also, up to and including PHP 5.3 we could attempt to echo an array without a notice given, but the word ‘Array’ would be echoed instead of any of the array’s content. Now in PHP 5.4 a notice is given:
Although it does still echo the word ‘Array’.
Here’s a great video (the keynote at PHPUK Conference in London) of Rasmus talking about the PHP project from the beginning, and about PHP 5.4: