PHP: Hypertext Preprocessor (or simply PHP) is one of those ubiquitous programming languages that underpins many of the most popular web platforms. PHP development began in 1994 as a personal project of Rasmus Lerdorf, who had created a series of Perl scripts which he referred to as his “Personal Home Page Tools” for the maintenance of his web page.
After being released worldwide, PHP underwent rapid refinement and development, with the second version of PHP/FI being released a mere two years later in November of 1997. PHP 3 was released in 1998, with PHP 4 and PHP 5 following in 2000 and 2004 respectively, PHP 6 was abandoned due to the difficulty of adding Unicode support. Finally, PHP 7 was released in 2015 and its subsequent minor versions releases in later years.
Out of all PHP releases till now PHP 7 was the most awaited because it came up with some fundamental changes & improvements in areas like performance, security, garbage collection, memory, the addition of new libraries, removed some of Deprecated Extensions and Features, etc.
In this article I’m going to provide details of important changes implemented and some useful tips of PHP 7 and why should you update immediately if you haven’t done yet.
Following are some of the topics I’m going to cover in a series of this article.
- PHP’s usage statistics
- Why should we update to the latest version of PHP 7 immediately?
- Features/functions removed/added in PHP 7
- Miscellaneous information/tips for PHP 7
1) PHP’s usage statistics
Below statistics, reports show PHP is still dominating as web server-side scripting language on the web and still been widely used by almost 79% of all the websites on the internet.
2) Why should we update to the latest version of PHP 7 immediately?
Upgrading to the latest version of PHP 7 comes with loads of speed, performance and security benefits, let us go in detail.
a) Support for PHP 7.1 and below officially ends
As a thumb rule in the software industry, as newer versions are released, support for the older versions gets dropped as more & more people upgrade & contribute. Older versions are maintained with security patches for a certain period of time to give website owners a chance to upgrade.
Below table shows the official list of currently supported versions of PHP & security support end dates.
As you can see from the above schedule PHP 7.1 is not actively developed or supported, it will only get security update support for next 7 months from now.
b) Improved security
Prior to PHP 7 version release, there were hundreds of security issues that got patched up over time. If your site running an earlier version of PHP so there are chances some of these vulnerabilities might still be present.
As per security vulnerability data source CVE details there were 64 known vulnerabilities found in PHP in last 2 years, vulnerabilities include DDoS, code execution, memory corruption, SQL injection, XSS and many other types of exploits.
To avoid security vulnerabilities, you should keep your version of PHP up-to-date. PHP 7 makes it harder to write poor code by default. Additionally, there are also a few new tools for serialization and cryptographically secure random numbers, better functionality for identifying content that is potentially dangerous (like malicious code injections) which makes PHP 7 strong.
c) Speed performance
PHP 7.x removed many outdated functions that were dragging down older versions, making it more efficient than ever before, and 7.2 takes it even further. This new, leaner version of PHP allows your site to load and respond much faster than previous versions. As an example, PHP 7.2 can serve up to 3x as many requests per second and handle more traffic with the same number of resources. It can handle un-cached site visits 2–3 times faster than PHP 5.5.
Below are performance benchmark results across various PHP versions tested on Wordpress & Drupal.
d) Enhanced efficiency in processing
Having an efficient version of PHP means a significant improvement in how your code is processed on the server: up to a 75% reduction in the number of commands issued when performing a single task.
You have set an amount of memory available for running PHP on your site. WordPress core or Drupal core, theme, and modules/plugin files all require varying amounts of that memory to run; the more complex the task, the more memory is required. And when they hit that limit of memory on your server — up comes the White Screen of Death (WSOD) with an ugly error message. So, in short, upgrading to PHP 7.2 means much less memory is required, allowing more cool stuff to happen on your site.
e) Stricter Development Standards
In the past, PHP has been pretty lax in how developers could use it, culminating in a ton of poor programming practices across the board. Earlier versions of PHP allowed the developer to write code with security holes and issues that could slow the performance of your site. PHP 7 and above, however, require a higher standard of coding from its developers.
Forcing these better programming practices in PHP 7 means higher quality, better performing code from the start.
PHP 7 comes with a lot of improvements over its predecessors that will directly benefit your PHP website/application. Regardless, it’s absolutely becoming a non-conditional requirement for running a secure and speedy website/application, so it’s important to make the switch sooner rather than later.
Reasons to upgrade to PHP 7. Let’s quickly summarize them:
1. The latest version of PHP for improved security and performance.
2. PHP 7 enforces better coding standards, improving coding standards across the board.
3. The latest PHP version can run significantly faster than its predecessors, which will improve your site’s speed as well.
OK, that’s up for Part 1. Thanks for sticking around!
Thank you for reading, and good luck as you migrate your code to PHP7. Check out below links to migrate/upgrade PHP version.