Call now! (ID:210759)
+1-855-211-0932
HomeBlogPHP 7 is here! What’s new in PHP 7?

PHP 7 is here! What’s new in PHP 7?


PHP 7 is finally here! After 8 release candidates and a few release date delays, the latest stable PHP has been released officially and now it is deployed on our web hosting platform as well. This release marks the begining of the new PHP 7.x series, which is a milestone in the programming world.

The history of PHP7 

PHP 6 was released into the world in 2005, and it was supposed to be the descendant of the PHP 5.x series. It offered a different encoding method where Unicode was brought into the PHP core engine, PHP 6 promised to change the coding landscape for good. However, that approach was not able to stand the real-world tests as the usage of CPU and memory resources was too high and this made PHP 6 too complex and resource-consuming to be put into practice.

It seemed like the PHP 5.x branch would have to release a candidate to lead the ‘new stable PHP version’ march. It was time to focus on internal optimizations, which brought to life the experimental PHPNG, also known as PHP 5.7.

PHP NG  took the best of both worlds by assimilating the worthy features of PHP 6, together with namespaces support, but relied on the performance and memory utilization algorithms initiated in the PHP 5.x series.

This is how the path to PHP 7 was paved. And since the web development community chose to take the new stable candidate out of the PHP 5.x branch stage, it was a logical step to move straight to PHP 7, skipping PHP 6.

What's new in PHP 7?

PHP 7 focuses on performance, meaning faster processing speeds and less memory consumption.

Also, it brings new operators and a range of type declarations to the table. Here are some of the main advantages in detail:

The biggest and most striking advantage of PHP 7 over the predecessor is the practically doubled real-world performance speeds.
This is a massive improvement and behind it lies the latest version of the Zend engine that has been implemented under the code name of PHP#NG.
The latest Zend Engine features a significant reduction in memory usage and a new just-in-time compilation (JIT) functionality, which resolved the previous prior-to-execution compilation problems.

Below, you can see for yourself the performance benchmark chart provided by the Zend Performance Team:

As you can see, the performance gain achieved by PHP 7 varies between 25% and 70% . In terms of real-world application usage, this is a massive improvement!

You can see the full infographic on PHP 7 performance on the Zend website

Apart from the doubled speeds, PHP 7 also gives developers the freedom to enhance the quality of their code through new accurate return type declarations.

Developers can now prevent unintended return values by declaring what kind of return type a function is expected to have.
PHP 7 brings in total of 4 new type declarations for scalar types, allowing developers to denote that they’re expecting strings, floats, ints or booleans to be returned.

The new scalar type declarations are also supported by the existing argument Type Hints.

php7_new-operators.png

PHP 7 has introduced a new operator – the Combined Comparison Operator, also known as the Spaceship Operator <=>.

What is the spaceship operator? Well it name probably comes from the fact that it looks like a TIE fighter and can be used for combined comparisons, in most cases when sorting is needed.

The spaceship operator allows developers to check if something exists. If it exists and is not null, the operator will return the result of its first operand, and if it doesn’t or in any other case, it will return the second operand.
Here’s how the new operator reduces the time spent with basic declarations:

The rules used by the combined comparison operator are same as the currently used comparison operators by PHP viz. <, <=, ==, >= and >. Those who are from PERL or RUBY programming background may already be familiar with this new operator proposed for PHP7.

Developers can now use anonymous classes with PHP 7 just like in other object-oriented languages like C# and Java.

The syntax of an anonymous class is the same as that of traditional PHP classes, the only difference being the missing name.
The main purpose of the anonymous classes is to speed up coding and execution times.

They do a great job in cases when a class is used once during execution or when a class doesn’t need to be documented.
Here is an example of an anonymous class as illustrated on PHP.net:

Developers and users can benefit from the amazing back-end coding and real-world performance gains of the new PHP release by simply upgrading their current PHP version.

There is no need to change a single line of code.

Developers and users can get the best of the new PHP without making any investment and they could need less processing power to serve the same amount of users.

These are just a few of the spectacular new features introduced in PHP 7. 
PHP 7 also includes: 

  • Abstract Syntax Tree
  • Facilitated error handling through exceptions – the new Engine Exceptions will allow developers to replace fatal and catchable fatal errors with exceptions, which are differentiated from the traditional  \Exception Base Class exceptions. Both exceptions can be used through the newly introduced \BaseException shared parent class.
  • Secure random number generator
  • Facilitated import from the same namespace – through the new Group Use Declarations syntax, developers will be able to import many classes from the same namespace, which makes the code tidier and saves a lot of typing time.
  • Removed old and unsupported SAPIs & extensions – to free up space for improvement, many deprecated functionalities and unsupported Server APIs and extensions have been removed.
  • Consistent 64-bit Windows OS support – although it is a LAMP member, through its latest version, PHP now supports native 64-bit integers and large files, allowing devs to run PHP on a 64-bit Windows platform as well.

More information on PHP 7 and more details on the new features can be found on the official community website.

How to enable PHP 7 for my websites and applications?

As everything else with iClickAndHost upgrading to PHP 7 is a breeze and happens with a simple click of a button. 
Just go to the Hepsia Control Panel and select PHP Settings from the Advanced menu. 
The ‘Choose a PHP version’ option will appear at the top of the page:


Do you need to sign up for PHP 7 hosting? Start here
PHP 7 is here! What’s new in PHP 7?
Rate this page