PHP7 – shorter loading and access time online

Keeping loading times to an absolute minimum is key when creating a website. Visitors who don’t have to wait a long time to access your site have a lower bounce rate and tend to stay longer. This is rewarded by search engines, like Google, in the form of a higher ranking. This fact alone shows that stepping on the gas is a worthwhile goal that can offer real results. Optimising your website’s script language is just one of the many of ways of speeding up a web presence. Developers of websites that rely on PHP in particular have benefitted from an even better performance since the release of PHP7. This could be improved even further with the recently released successor versions 7.1 and 7.2.

Note

The use of obsolete PHP versions, which will include 7.0 from December 2018, could pose a potential security risk. The PHP community only supports current versions such as PHP 7.1, PHP 7.2, or the future PHP 7.3.

Shortly after the security support for PHP 7.0 expires, so does the official support for the popular PHP 5.6 in December 2018. This signifies that the new version of the scripting language is on its way. Two years after the first release, PHP7 is finally arriving on the internet.

So what is PHP?

PHP is a scripting language used for drafting dynamic websites. The language is shared under the PHP license, which allows users to continue using and changing source code free of charge. Basic PHP functions include reading form data and converting it into PHP variables. These variables can be entered into a database or sent via e-mail. PHP is able to support a wide range of database models as well as being able to integrate common web technologies. In addition, it is used by approximately 82% of all websites, adding strong and expert-level community support to its list of advantages. 

All PHP codes are processed server-side. This means that PHP scripts—in contrast to JavaScript, which is carried out on browsers—are executed directly on the server. When a user sends a request to a server, the respective PHP script is sent to the PHP interpreter located on the server. The interpreter then processes the script and forwards the results to the web server, which sends the page to the browser. Usually HTML documents are created, though other file types can also be present. JPG or PDF documents can be generated and sent to the browser with the help of PHP.

What new features does PHP7 offer?

Since PHP6 was never fully developed, PHP7’s release signalled the end of PHP5 and simultaneously rung in the sixth instalment of the programming language. The scripting language itself changed little with the release, which is why PHP7 largely remains downwardly compatible. This feature allows almost all applications, even those designed for previous versions, to run on PHP7. Compatibility issues may still arise when dealing with older extensions that no longer receive regular updates. The best example for this is the old extension for accessing MySQL databases that is no longer supported in version 7. Switching to the better MySQLi extension or the comparable PDO (PHP Data Objects), is therefore recommended in such cases.

Perhaps the most attractive new feature of PHP7 is its performance boost, which enables developers to better optimise the core of PHP. In addition to the improved speed (PHP7 is about twice as fast as its predecessor), the new version also takes up less working memory. Not only has the execution of the compiled bytecode been completely renovated, but other core components have also seen fundamental changes, including the parser, lexer, and bytecode generator. Instead of drafting code directly out of the parser, PHP7 creates an abstract syntax tree that establishes the basis for generating bytecode commands.

Another feature is that users are now able to define scalar data types - data types that only store one single value – and return types in the program code. In this way, PHP is extended by the integer, Boolean, float, and string types.

The most important features and advantages of PHP7

✔ Greatly improved performance, around twice as fast as PHP5.6

✔ Lower working memory demands

✔ Implementation of an abstract syntax tree for generating bytecode

✔ Thorough support of 64 bit systems

✔ Improved error handling, errors less frequently lead to crashes

✔ Cryptographically secure pseudo-random number generator

✔ Removal of old or redundant extensions and server interfaces

✔ Ability to define scalar and return data types

How PHP7 improves the performance of WordPress and Co.

PHP7’s improved performance is based on the integration of the branch PHPNG (PHP Next Generation) into the main version of PHP. The branch is characterised by its refactored core, which includes the new Zend Engine 3.0.  During the first benchmark tests, prior to the PHP7 release, it became clear that Zend Technologies’ new version offers numerous advantages for online shop solutions, content management systems, and frameworks.

Tip

1&1 IONOS is the only host that ensures that old PHP versions can run without security problems even after the end of PHP community support. Thanks to PHP extended support, the customer can decide for themselves when or if they want to convert.

The eCommerce software Magento can be executed at twice the speed of PHP5.6, thereby reducing memory use by around 30%. Additionally, PHP7 can handle up to three times as many hits from visitors than the preceding version. Results from tests with CMSs (content management systems) fare similarly: Drupal 8 increases its speed by 72%, and WordPress tests have shown to require only a quarter of the CPU instruction required for a hit. Both CMS systems showed an increase of around 50% in terms of possible page views. The frameworks Laravel, Zend, as well as the CRM software, SugarCRM, allow PHP7 to double the amount of hits per second.

In comparison to earlier versions, PHP7 is able to cope with much higher rates of traffic. This means equipping your setup with robust hardware in order to deal with more visitors may not be necessary. The new PHP7 performance fulfils the demands required for running WordPress, Magento, or similar projects without generating additional costs.

Details on the benchmark data from Zend Technologies are available in this infographic.