On the heels of the launch of PHP 7, I thought it would be interesting to see the evolution of PHP. The focus here is mostly on the evolution of PHP starting with PHP 5.0 which was released almost a decade ago. Objects were introduced in Version 4, but PHP didn’t really become a more modern object oriented language until version 5. It’s when the language really started to grow up.
Let’s take a look at what each version of 5 brought us.
Version 5 continues the move toward object oriented programming
Zend Engine 2, which greatly improved PHP’s performance
PHP 6 was a false start and development was eventually abandoned in favor of V7. I never used it but from the sound of it I didn’t miss much.
If for some reason you are using PHP 6, upgrade to 7 ASAP!
As mentioned earlier, PHP 7 is huge step forward. Type declarations will make code less error prone and the the 2x speed improvement will speed up your site.
Scalar type declarations
Scalar type declarations come in two flavours: coercive (default) and strict. The following types for parameters can now be enforced (either coercively or strictly): strings (string), integers (int), floating-point numbers (float), and booleans (bool). They augment the other types introduced in PHP 5: class names, interfaces, array and callable.
Return type declarations
Null coalescing operator
The null coalescing operator (??) has been added as syntactic sugar for the common case of needing to use a ternary in conjunction withisset(). It returns its first operand if it exists and is not NULL; otherwise it returns its second operand.
Spaceship operator (<=>)
Constant arrays using define()
Group use declarations
Generator Return Expressions
list() can always unpack objects implementing ArrayAccess