PHP 7.0 Available on All Servers

August 20, 2015

If you've been excitedly watching the development of PHP 7 like we have, you've been looking forward to this day for more than a year. Today, PHP 7.0 RC1 was released. This is the first release candidate for PHP 7.0 and marks the end of beta for PHP 7.

With this release, we're proud to announce PHP 7.0 is now available on all servers.
EDIT: As of September, 2019, PHP 5.6, 7.0, and 7.1 are no longer installed by default with ServerPilot, as they are beyond end-of-life. PHP 7.2 and above continue to be supported.

Advantages of PHP 7

The main focus of PHP 7 is improving performance. Over the last few years, the developers of PHP have been hard at work on a project called PHP Next Generation (PHPNG). The goal of PHPNG was to redesign the Zend Engine—the name for the PHP interpreter—to enable massive improvements in PHP's performance.

The result: a completely redesigned interpreter that executes PHP scripts tremendously faster while at the same time using much less memory.

Speed Improvements

Despite PHP 5.6 already being significantly faster than all previous PHP versions, PHP 7.0 more than doubles the speed of most applications. And this isn't the end of the speed improvements coming to PHP. The major work that went into PHP 7.0 also lays the groundwork for further speed improvements in PHP 7.1 and beyond.

Memory Efficiency

PHP 7.0 redesigns and heavily optimizes many internal value representations and data structures to reduce memory usage. In PHP 7.0, data structures such as arrays use up to 3.5 times less memory than in PHP 5.6.

Language Enhancements

Although the amazing performance enhancements of PHP 7 deserve most of the attention, PHP 7 also has some great new language features.

Scalar type declarations

Function parameters can now be forced to be strings, integers, floating-point numbers, or booleans. By default, PHP will coerce values of the wrong type into values of the declared type. An optional strict mode will raise an error when an argument of the wrong type is passed to a function.

Return type declarations

Like argument type declarations, return type declarations specify the type returned from a function.

Null coalesce operator

The null coalesce operator (??) simplifies the common case of needing to use a ternary in conjunction with isset(). It returns its first operand if it exists and is not NULL; otherwise, it returns its second operand.

// Fetches the value of $_GET['user'] and returns 'nobody'
// if it does not exist.
$username = $_GET['user'] ?? 'nobody';
// This is equivalent to:
$username = isset($_GET['user']) ? $_GET['user'] : 'nobody';
Spaceship operator

The spaceship operator (<=>) simplifies comparing two expressions.

// Strings
echo "a" <=> "a"; // 0
echo "a" <=> "b"; // -1
echo "b" <=> "a"; // 1
Constant arrays using define()

Array constants can now be defined with define(). In PHP 5.6, they could only be defined with const.

See the entire list of new language features.

What about PHP 6?

Don't worry; you didn't miss anything. There is no PHP 6. The developers of PHP decided to skip version 6 so as not to confuse anyone. As silly as that sounds, that's really the answer.

A few years ago, the developers of PHP had discussed a possible PHP 6 with a specific set of features. They ultimately decided not to proceed with PHP 6 and continued working on the PHP 5 branch. Later, when they again decided to focus on a new major version, they felt it would be less confusing to call it PHP 7 so nobody would think they were talking about the same features previously discussed for PHP 6.

App Compatibility

Like any major version change, some apps will require code changes to be compatible with PHP 7. Happily, major apps like WordPress have already added support for PHP 7. If you find that your WordPress plugins or themes, or other apps you use, aren't compatible with PHP 7, you should continue using PHP 5.6 and report the incompatibility to the app's developer.

Learn more about backward incompatible changes in PHP 7.0.

Extension Compatibility

If your apps rely on PECL extensions or third-party PHP extensions such as ionCube, you'll need to wait for the extension developer to add PHP 7 support.

Check the PHP 7 compatibility of PECL extensions.

How to Switch to PHP 7.0

To use PHP 7.0 with one of your apps, go to the app's Settings in ServerPilot and change the Runtime to PHP 7.0 RC.

As always, your servers and apps using PHP 7.0 will automatically receive updates as new PHP 7.0 releases become available. When PHP 7.0.0 is released, all apps using PHP 7.0 RC will automatically begin using PHP 7.0.0.