November 24, 2024

PHP 7: What’s New & How Will It Affect a WordPress Site?

PHP7

PHP 7, a major update to the server-side web development language PHP, is right around the corner. According to PHP 7 project timetable mentioned on PHP.net wiki, if everything goes as planned, its final version will be released on Nov 12, 2015. Meanwhile, you as a future user may consider playing around with the latest beta to have an overview of what features the new version of PHP offers and how it will shape up and affect your development work.

If you’re a website developer/owner running their sites on WordPress (or on any other PHP-powered CMS such as Joomla, Drupal, Magento), then you’ve landed to the right blog post. This informative guide will not only give you a taste of what’s new coming in PHP 7 but also will answer all your questions related to the new PHP version!

Wordpress-php7-performance

Drupal on PHP7

Let’s dive in!

What’s New in PHP 7?

First of all, let’s take a closer look at some of the exciting features and improvements that you’ll see in PHP version 7:

Huge Performance Improvements:

PHP has always been criticized for performance-related issues, which is greatly improved in PHP 7. Even, the poor performance of PHP prompted Facebook to build HHVM – a virtual machine designed to maximize the performance of PHP based applications. Since the new version of PHP is based on the PHPNG project (PHP Next-Gen), it gives up to 50% boost to real-world apps and performs faster than HHVM.

Twice as fast as Previous Versions:

PHP 7 is almost 2X faster than PHP 5.x. It not only executes your code faster but also requires fewer servers to handle the same amount of requests per second. As an example, the WordPress homepage now requires 72% lesser CPU instructions to execute than before. That’s because PHP 7 receives a brand new version (refactored) of Zend Engine, which adds a significant speed enhancement to the language.

New Operators:

PHP 7 introduces two new operators: Spaceship (Combined Comparison) and Null Coalescing. Where the Spaceship operator (<=>) makes your chained comparison more concise, on the other hand, Null Coalescing (??) operator is used to check if something exists. However, these both tasks could be accomplished before, but probably not in all conditions.

Return & Scalar Type Hints:

In the new PHP version, developers would be able to use Booleans, Strings, Floats and Integers as type hints for functions. Also, they’ll be allowed to declare the return type of a function. This will save them passing and returning wrong types from functions, which may lead to unpredictable behavior in code.

Engine Exceptions:

Handling existing fatal and recoverable fatal errors has always been a herculean task for PHP developers. But now, exceptions implemented in the brand spanking new Zend engine will facilitate error handling in your application. The new Engine Exceptions will replace these kinds of errors, making it possible for developers to catch all fatal errors and take appropriate action immediately.

Consistent 64-Bit Support:

Even though the native environment of PHP is Linux, but still you can run it on a Windows-powered system. Since the previous versions of PHP doesn’t have support for a large file or 64-bit integer, the x64 builds of PHP for Windows have been considered experimental yet. To the contrary, version 7 features consistent 64-bit support that enables you to confidently run PHP on a 64-bit Windows system.

Group Use Declarations:

PHP 7 introduces a new concept, called Group Use Declarations, which dramatically improves the implementation of PHP namespace. The new syntax makes it possible for you to import multiple classes from the same namespace. Needless to say, this new feature will save you a lot of typing time and also make your code shorter and readable.

Supports Anonymous Classes:

Like other programming languages such as Java and C#, the new version of PHP enables you to use anonymous classes in your code. An anonymous class is a class with no name. When used properly, anonymous classes can not only improve your coding but also can speed up execution time to a great extent.

Abstract Syntax Tree (AST):

Another big change made to PHP core is the use of Abstract Syntax Tree (AST) as an intermediary stage in the language compilation process. This improvement would mainly be visible to developers and not have any direct impact on userland code. There are several advantages of using AST, including the potential for more optimizations, the scope for utilizing tools like static code analyzers and better code quality etc.

Deprecated Items Removed:

To make PHP even faster, a number of deprecated functionalities and dead or unsupported Server APIs and extensions have been eliminated from the version 7.  Some of the items that are removed from PHP 7 are PHP4 style constructors, ASP style tags, ereg and MySQL extensions etc. For more details, you may check out removed deprecated functionalities in PHP7.

But, where is PHP 6?

After getting acquainted with the exciting features of PHP 7, you would definitely want to know why PHP moved to version 7 from version 5. What happened to version 6? Well, PHP 6 was an experimental project that was officially started in 2005 and unfortunately abandoned in 2010. One of the main reasons behind the termination of version 6 was technical difficulties faced by PHP core developers during the implementation of language-integrated Unicode.

Meanwhile, people around the web adopted the name PHP 6 and started writing books and developing resources related to version 6. Since there might be confusion between the former attempt and the current development work, the PHP core team was compelled to seriously think about the name of the new major release. And finally, the development team decided to skip the logical number 6 and launch the new version under the name of PHP 7.

How Can PHP 7 Really Affect Your WordPress Site?

Despite the fact that WordPress core development team is continuously working on making the CMS ready for PHP7, the latest version of PHP can break your site. The reason is the incompatibility of themes and plug-ins with PHP 7. Even though WordPress has suggested theme and plugin authors to get familiarize with all backward incompatible changes and update things accordingly, most of the themes and plug-ins are not yet ready for the upcoming release of PHP 7.

Since WordPress has started fixing every possible issue related to PHP 7, more and more people are now taking necessary steps toward making their themes and plug-ins compatible to PHP 7. For instance, the author of Simple Social Icons has already updated the plug-in to make it PHP 7compatible. That means, soon after PHP 7 official release, not only WordPress would fully support PHP 7 but also all themes and plug-ins would have been updated to work with version 7. In a nutshell, consider upgrading your site to PHP 7 only when you found everything – hosting server, themes, plug-ins and WordPress – compatible to version 7.

Crucial Things to Consider When Migrating from PHP 5 to PHP 7

So if you’ve decided to move your WordPress site from PHP 5 to PHP 7 right after the official release of version 7, here are some best practices that you should follow to prevent any issues before, during and after migration:

Watch for Notifications:

Before implementing any PHP update, most of the hosting providers send a notification to site owners. The purpose of this notification is to make you inform about the update so that you could keep a look out to see if something goes wrong. So continuously watch for notifications and inform your hosting provider immediately if you found anything wrong.

Backup Your WordPress Site:

Even if you’re fully confident that the PHP update will not break your website, it’s always good to have a fallback plan. Whether or not you receive the notification from your hosting provider, always have a saved copy of your site on multiple locations. This will save you from any unforeseen disaster that may occur during migration.

Keep Everything Updated before Migration:

Before moving to PHP 7 from PHP 5, update all elements – including themes, plugins and WordPress itself – related to your WordPress site. This will prevent these (and other) elements from stop working after PHP gets updated. Also, if a certain element is not compatible with the new version of the language, it’ll no longer function.

Contact Your Hosting Provider:

For further help, you may consider contacting your web host’s support team. In case, your web host is unable to completely resolve your issues, then install a new copy of WordPress and restore your site from a backup.

Author Bio
Ajeet is a senior web developer at WordPress Integration – PSD to WordPress service provider, where he is responsible for writing custom JavaScript code during the conversion process. In his spare time, he writes on different topics related to WordPress, JavaScript and Web Design to share his work experience with others. You can follow WordPressIntegration on Facebook

Share

Ajeet is a senior web developer at WordpressIntegration - a PSD to WordPress service provider where he is responsible for writing custom JavaScript code during the conversion process. In his spare time he writes on topics related to JavaScript, WordPress, and Web Design. You can learn more by following WordpressIntegration on Facebook.

6 Comments

  1. geminiITSolutionsUK Reply

    i have just moved over to PHP 7 ( mysql 5.6 -percona server) and as my web hosting company still has this in beta,i was advised not to use PHP 7 on a live production website,I did encounter a few issues but this was only because i have a multi-site set up in place with the website that uses the new PHP 7.i have only been using wordpress for about a year now which i host on my own virtual host platform

Leave a Reply

Your email address will not be published. Required fields are marked *