Evolution of the PHP Language

PHP is a language for the web, the most popular one in fact.  That’s not to say it’s the best, or the worst for that matter but the number of webpages powered by PHP outweighs all the other languages including JAVA, python, Ruby on Rails, etc.

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.

PHP 5.0

Version 5 continues the move toward object oriented programming

New Features

  • Zend Engine 2, which greatly improved PHP’s performance
  • MySQLi, or improved MySQL, was introduced
  • SQLite is now built into PHP

For more information check out, http://php.net/manual/en/migration5.incompatible.php

PHP 5.1

New Features and Improvements

  • Support for custom autoloading was eventually a game changer for PHP framework creators
    • spl_autoload_register in PHP 5.1.2
  • A complete rewrite of date handling code, with improved timezone support.
  • Significant performance improvements compared to PHP 5.0.X.
  • PDO extension is now enabled by default.
  • Over 30 new functions in various extensions and built-in functionality.
  • Over 400 various bug fixes

For more information check out, http://php.net/manual/en/migration51.changes.php

PHP 5.2

New Features

  • Improved memory manager and increased default memory limit. The new memory manager allocates less memory and works faster than the previous incarnation.
  • New Extensions (The following are new extensions added (by default) as of PHP 5.2.0)
    • Filter – validates and filters data, and is designed for use with insecure data such as user input. This extension is enabled by default; the default mode RAW does not impact input data in any way.
    • JSON – implements the JavaScript Object Notation (JSON) data interchange format. This extension is enabled by default.
    • Zip – enables you to transparently read or write ZIP compressed archives and the files inside them.

PHP 5.3

One of the most important updates to PHP that I can think of.  Don’t be surprised if you come across a site that is still running version 5.3 (however this is not recommended 😉

New Features

  • Support for namespaces has been added
  • Support for Late Static Bindings has been added
  • Support for jump labels (limited goto) has been added.
  • Support for native Closures (Lambda/Anonymous functions) has been added.
  • There are two new magic methods, __callStatic() and __invoke().
  • Nowdoc syntax is now supported, similar to Heredoc syntax, but with single quotes.
  • It is now possible to use Heredocs to initialize static variables and class properties/constants.
  • Heredocs may now be declared using double quotes, complementing the Nowdoc syntax.
  • Constants can now be declared outside a class using the const keyword.
  • The ternary operator now has a shorthand form: ?:.
  • The HTTP stream wrapper now considers all status codes from 200 to 399 to be successful.
  • Dynamic access to static methods is now possible

For more information check out, http://php.net/manual/en/migration53.new-features.php

PHP 5.4

Traits and built in development web server are really cool.  Although they have been here since 5.4 some folks are just now using them.

New Features

  • Support for traits has been added.
  • Short array syntax has been added, e.g. $a = [1, 2, 3, 4]; or $a = [‘one’ => 1, ‘two’ => 2, ‘three’ => 3, ‘four’ => 4];.
  • Function array dereferencing has been added, e.g. foo()[0].
  • Closures now support $this.
  • <?= is now always available, regardless of the short_open_tag php.ini option.
  • Class member access on instantiation has been added, e.g. (new Foo)->bar().
  • Class::{expr}() syntax is now supported.
  • Binary number format has been added, e.g. 0b001001101.
  • Improved parse error messages and improved incompatible arguments warnings.
  • The session extension can now track the upload progress of files.
  • Built-in development web server in CLI mode.

the <?= tag has been a contentios item in some code bases, especially with larger teams, it’s great that it is always available now.  It’s cleaner and easier to write than <?php echo

For more information check out, http://php.net/manual/en/migration54.new-features.php

The page on traits is worth a read too, http://php.net/manual/en/language.oop5.traits.php

PHP 5.5

New Features

  • finally keyword added
  • password_hash()
  • foreach now supports list()
  • empty() supports arbitrary expressions
  • array and string literal dereferencing
  • Generators added

For more information check out, http://php.net/manual/en/migration55.new-features.php

To learn more about Generators read, http://php.net/manual/en/language.generators.overview.php

PHP 5.6

New Features

  • Constant expressions
  • Variadic functions can now be implemented using the … operator, instead of relying on func_get_args().
  • Arrays and Traversable objects can be unpacked into argument lists when calling functions by using the … operator. This is also known as the splat operator in other languages, including Ruby.
  • A right associative ** operator has been added to support exponentiation, along with a **= shorthand assignment operator.
  • use function and use const
    • The use operator has been extended to support importing functions and constants in addition to classes. This is achieved via the use function and use const constructs, respectively.
  • phpdbg – PHP now includes an interactive debugger called phpdbg implemented as a SAPI module.
  • Default character encoding
  • php://input is reusable
  • Files larger than 2 gigabytes in size are now accepted.
  • GMP supports operator overloading
  • hash_equals() for timing attack safe string comparison
  • The __debugInfo() magic method has been added to allow objects to change the properties and values that are shown when the object is output using var_dump().
  • gost-crypto hash algorithm
  • SSL/TLS improvements
  • pgsql async support

For more information check out, http://php.net/manual/en/migration56.new-features.php

PHP 6?

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!

PHP 7

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.

New Features

  • 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()
  • Anonymous classes
  • Closure::call()
  • Filtered unserialize()
  • Expectations
  • Group use declarations
  • Generator Return Expressions
  • Generator delegation
  • Session options
  • preg_replace_callback_array()
  • CSPRNG Functions
  • list() can always unpack objects implementing ArrayAccess

For more information check out, http://php.net/manual/en/migration70.new-features.php

Other useful PHP7 links

Bonus Points

Do you remember what PHP stood for originally?

Next Post

Comments

See how we can help

Lets talk!

Stay up to date on the latest technologies

Join our mailing list, we promise not to spam.