Chat with us, powered by LiveChat

This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

What’s New in PHP 7.3 (Now Available on Cloudways)

March 28, 2019

8 Min Read
Reading Time: 8 minutes

Cloudways is pleased to announce the availability of PHP 7.3 on the platform.

This integration comes after numerous request from customers who wanted to leverage the benefits of PHP 7.3 and improve the performance of their apps. All major PHP frameworks have released new versions that takes full advantage of the features offered by PHP 7.3 hosting.

After extensive testing to ensure complete compatibility of the integration with the Cloudways Platform, our engineers finalized the availability of PHP 7.3 on the platform. At the moment, PHP 7.0 is the default available version for all PHP applications launched on our Platform, but you can easily upgrade to PHP 7.3 within minutes.

If You Already Have a PHP Application

Upgrading your Cloudways server to PHP 7.3 is pretty easy. However, before making the move, you should check for version compatibility of your app because a mismatch can cause operational challenges that would need you to dedicate time to troubleshooting.

To upgrade, just go to the Settings & Packages , and then to the Packages tab. From the dropdown, select PHP 7.3 and hit the Save button. Now wait for a  few minutes as PHP 7.3 gets set up on your server.

As soon as you see the success notification, go to the SSH terminal, login with your master credentials and run the

php -v

command to verify that the PHP version has been upgraded:

PHP 7.3 is a major step forward for PHP community. We hope that our users will be able to utilize this integration to add more power to their apps. We invite all to try out PHP 7.3 and share their experiences at the Cloudways Community Forum.

What About Existing Servers?

At the moment, you can launch managed PHP servers that support all popular versions including 5.6, 7.0, 7.1 and 7.2  with 7.0 being the default offering. All existing servers will continue to function with the currently selected PHP version.

You can easily switch between PHP versions by going to Server > Access detail > Settings & Packages tab, and then select the required PHP version from the dropdown.

We highly recommend you check the compatibility of your application / website before upgrading or downgrading PHP versions. In case of issues, you could discuss the problem with our support.

Now that you know how to launch PHP 7.3 on Cloudways, we have compiled a list of PHP 7.3 features and updates. The list contains the deprecation in code and new features:

Let’s discuss the above updates one by one in detail.

Flexible Heredoc and Nowdoc Syntaxes

Heredoc and Nowdoc syntax help out the users in using multi-line long strings. It requires that the ending identifier should be the first string appearing in a new line.

// Instead of this:

$query = <<<SQL


FROM `table`

WHERE `column` = true;


// You can do this:

$query = <<<SQL


   FROM `table`

   WHERE `column` = true;


Basically this update proposed two new changes which are as follows

  1. To enable the closing marker for indenting
  2. To remove the new line requirement after the closing marker

In the example, mentioned above, you can see both of the changes easily.

Deploy PHP Apps Without Worrying About Servers

Our Managed Cloud Hosting for PHP applications takes care of all hosting related hassles

Allow a Trailing Comma in Function Calls

Appending of trailing commas is made at the end of listed parameters, elements and variables. Several times we call a number of elements in an array or function call (especially variadic functions), in which if you have missed a comma, you will get an error. For that purpose, trailing commas can be useful there. They are allowed in arrays and from PHP 7.2 in grouped namespace syntax.

use Foo\Bar\{

$foo = [

As new values are appending here, so trailing commas are highly useful in this case. While in variadic functions like unset(), they will do the work fittingly well.


Meanwhile when you send a list of variables through compact() function to a templating engine, is also another example, you can use.

echo $twig->render(

You often need to merge arrays with array_merge() function in some situations where concatenation or grouping of data is constructed. You can use trailing commas there:

$newArray = array_merge(
   ['foo', 'bar'],

Similarly, you can use them in methods, function’s arguments and closure calls.

class Foo
 public function __construct(...$args) {

 public function bar(...$args) {

 public function __invoke(...$args) {

$foo = new Foo(




For parsing JSON responses, we have two functions available json_encode() and json_decode(). Unfortunately, both of them do not have a proper error throwing representation. Json_encode() will throw only false error whereas json_decode will throw null, and null can be true value. Only the way to know the error is to call json_last_error() or json_last_error_msg(), which returns the global error state in machine-readable and human-readable forms.

The proposed solution is to add JSON_THROW_ON_ERROR in both functions which ignores the global error state. While if an error occurs that would otherwise set it, these functions instead throw a JsonException with the message and code set to whatever json_last_error() and json_last_error_msg() throw. You can call it as:

json_encode($data, JSON_THROW_ON_ERROR);

json_decode("invalid json", null, 512, JSON_THROW_ON_ERROR);

// Throws JsonException

PCRE2 Migration

PHP uses PCRE for regular expressions. But from PHP 7.3, PCRE2 will come into action for regular expressions. Therefore, you need to migrate your existing regex according to PCRE2 rules. These rules will be more aggressive than before. For instance see the regex:

preg_match('/[\w-.]+/', '');

This regex will fail now and will not throw a warning error. Because PCRE2 is strict about moving hyphen to the end or escaping for this work.

These features and more are available with the upgrade to PCRE2 10.x,

  • Forward relative back-references, \g{+2} (mirroring the existing \g{-2})
  • Version check available via patterns such as (?(VERSION>=x)…)
  • (*NOTEMPTY) and (*NOTEMPTY_ATSTART) tell the engine not to return empty matches)
  • (*NO_JIT) disable JIT optimization
  • (*LIMIT_HEAP=d) set the heap size limit to d kilobytes
  • (*LIMIT_DEPTH=d) set the backtracking limit to d
  • (*LIMIT_MATCH=d) set the match limit to d

list() Reference Assignment

PHP has list() assignment and reference assignment functions. But in the current state you cannot use reference assignment in list(). From now onwards, PHP 7.3 will allow you to use that. The new improved syntax is as follows:

$array = [1, 2];
list($a, &$b) = $array;

This is equivalent to this form:

$array = [1, 2];
$a = $array[0];
$b =& $array[1];

New PHP 7.3 changes will also enable us to use this with nested list and foreach() function:

$array = [[1, 2], [3, 4]];
foreach ($array as list(&$a, $b)) {
   $a = 7;

is_countable function

In PHP 7.2, you can count objects and arrays via count() function. If the object is not countable, PHP throws a warning. You need to check if the object or variable is countable or not. While PHP 7.3 now has new is_countable() function that returns if the passed variable is well countable or not.

This is a new type function that returns true if the given value is an array type or an instance of the Countable interface.


if (is_array($foo) || $foo instanceof Countable) {
   // $foo is countable


if (is_countable($foo)) {
   // $foo is countable

array_key_first(), array_key_last()

Currently PHP allows you to retrieve array first and last key/value by changing the internal state of the array when using reset(), end() and key() methods. Now to avoid this disturbance in internal state, PHP 7.3 proposes new functions for this task and added to the core:

  • $key = array_key_first($array); To gather first key of array
  • $key = array_key_last($array); To gather last key of array
  • $value = array_value_first($array); To gather first value of array
  • $value = array_value_last($array); To gather last value of array

Lets see the example:

// usage of an associative array
$array = ['a' => 1, 'b' => 2, 'c' => 3];

$firstKey = array_key_first($array);
$lastKey = array_key_last($array);

assert($firstKey === 'a');
assert($lastKey === 'c');

// usage of a numeric array
$array = [1 => 'a', 2 => 'b', 3 => 'c'];

$firstKey = array_key_first($array);
$lastKey = array_key_last($array);

assert($firstKey === 1);
assert($lastKey === 3);

Argon2 Password Hash Enhancements

In previous versions of PHP, we got Argon2 Password hashing which is a modern algorithm to secure passwords using hashes. It comes in three different types, Argon2i, Argon2d and Argon 2id. Argon2i is optimized for password hashing and password-based key derivation. Argon2d is faster and uses data-depending memory access. Argon2i instead uses data-independent memory access. Argon2id is a hybrid of Argon2i and Argon2d, using a combination of data-depending and data-independent memory accesses.


Argon2id is now the recommended Argon2 variant to use in paswword_* functions.

// Argon2id by name with custom cost factors behaves the same as PASSWORD_ARGON2I
password_hash('password', PASSWORD_ARGON2ID, ['memory_cost' => 1<<17, 'time_cost' => 4, 'threads' => 2]);


The password_verify() function works with Argon2id in addition to Argon2i.


This function will also accept Argon2id hashes and if any cost factors change, this will return true.

$hash = password_hash('password', PASSWORD_ARGON2ID);
password_needs_rehash($hash, PASSWORD_ARGON2ID); // false
password_needs_rehash($hash, PASSWORD_ARGON2ID, ['memory_cost' => 1<<17]); // true

Deprecate and Remove image2wbmp()

This function returns the WBMP or bitmap image format. Another function imagewbmp() is also available doing the same thing that is supposed to handle the necessary monochrome conversion. Hence, due to the duplication the image2wbmp() is now deprecated and you can now replace this function with imagewbmp().After the deprecation, each call to image2wbmp() would issue a deprecated warning. After the removal, each call to image2wbmp() would raise a fatal error.

Deprecate and Remove Case-Insensitive Constants

Right now you can use both case-sensitive and case-insensitive constants. But case-insensitive constants were creating bit complexities in usage. Therefore, to address this, PHP 7.3 proposes to deprecate case-insensitive constants.

Currently the situations is like:

  • Class constants are always case-sensitive.
  • Global constants declared with const are always case-sensitive. Note that this applies only to the short name of the constant, while namespaces in PHP are always case-insensitive.
  • Constants declared with define() are case-sensitive by default.
  • It is possible to declare case-insensitive constants by passing true as the third parameter of define().

Now the PHP 7.3 proposed deprecater to remove these items:

  • In PHP 7.3: Deprecate calling define() with third parameter true.
  • In PHP 7.3: Deprecate accessing a case-insensitive constant with a casing that differs from the declaration-site. The constants true, false and null are exempt from this.

Same Site Cookie

PHP 7.3 proposes to add the same site flag when issuing cookies. This will affect four core functions.

  1. setcookie
  2. setrawcookie
  3. session_set_cookie_params
  4. session_get_cookie_params

The effect will take place in two possible ways. Either it will add new argument to the function or will allow an array of options for moving all cookie options in there.

bool setcookie(

   string $name

   [, string $value = ""

   [, int $expire = 0

   [, string $path = ""

   [, string $domain = ""

   [, bool $secure = false

   [, bool $httponly = false ]]]]]]


bool setcookie (

   string $name

   [, string $value = ""

   [, int $expire = 0

   [, array $options ]]]


// Both ways work.

You Might Also Like: How to Use Redis for PHP Session Management

Updates to FPM

FastCGI process manager has also got an update and now comes with new options for customizing FPM logging.

log_limit: Set up the allowed length for log messages. This limit could be more than 1024 characters without wrapping

log_buffering: This allows experimental logging without extra buffering

decorate _workers_output: Use this pool option to disable the output decoration for workers output when catch_workers_output is enabled.

Windows File Deletion Improvements

As mentioned in the official release documentation:

“File descriptors are opened in shared read/write/delete mode by default. This effectively maps the POSIX semantics and allows to delete files with handles in use. It is not 100% same, some platform differences still persist. After the deletion, the filename entry is blocked, until all the opened handles to it are closed.”

Final Words

So above we have seen different updates, deprecation and new PHP 7.3 features included in the latest release. These are available on the website and merged to the master branch. You can now use the files in live servers. You can also move to official page for the detailed version of everything defined above. While if you still have any questions regarding this blog or new PHP 7.3 , feel free to write your comments below in the comments section.

If you like the article and find it helpful you can follow me on twitter for more updates and retweet 🙂

Share your opinion in the comment section. COMMENT NOW

Share This Article

Launch PHP websites without the worry of Server Management.

Pre-Installed Optimized Stack with Git, Composer & SSH

Shahroze Nawaz

Shahroze is a PHP Community Manager at Cloudways - A Managed PHP Hosting Platform. Besides his work life, he loves movies and travelling. You can email him at

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

BFCM 2019