PHP 5.6 is now available!

PHP 5.6 is now available!

The PHP team released PHP 5.6 yesterday, and we have made a tradition of supporting new PHP versions right as they come out.

Starting today, you can select PHP 5.6 for each of your web sites in the Gigahost Control Center!

While most readily available CMS and other scripts do not yet require the use of PHP 5.6, you may find it useful to switch already if you plan on using any of the new features in PHP 5.6:

Simple expressions supported in constants

Constants are no longer restricted to being a static value. Their values may now include simple calculations that depend on other constants, like so:

const ONE = 1;
const TWO = ONE * 2;

A new operator for calculating exponentials, **.

Curiously, PHP didn't have an operator for exponentiation until now. You had to use the pow() function. Now, to calculate 24, you just do 2 ** 4, which would give you 16.

Argument unpacking

If you have an array containing some items, you can use an array as the arguments for a function using the ... operator.

$arguments = [1, 2, 3];
This would call my_function(1, 2, 3).

Variadic functions

Similarly, a function can receive its parameters as an array using the ... operator.

function my_function(...$arguments) {

In the above example, calling my_function(1, 2, 3) would print an array containing the three integers.

… and more

There are a lot of minor tweaks and improvements in PHP 5.6, such as a new way to set the default character set, operator overloading in GMP, constant-time hash comparisons, a GOST hashing algorithm, improved SSL security, and a magic __debugInfo() method to add to what var_dump will tell about an object. For a complete overview, see PHP's New features page.

Try out the new PHP version by selecting one of your domain names in the Control Center, and then choose “PHP version”. You can always revert to any of the other supported versions, PHP 5.5, 5.4, 5.3, and 5.2.