bookmark_borderHow to update PHP 5 to 7?

Updating is never 100% painless, but the team behind PHP has tried its best to lower the incompatibilities and provide a good experience during the process of updating from PHP 5 to 7. 

Migration tools 

Before moving your application from PHP 5 to 7, you should most definitively back up. You don’t want to lose your work. You can also use various migration tools that can tell you in advance what part of the code most probably won’t work and how to fix it. Check one of these 3: 


php7mar is a simple tool that generates reports. It will show which line of code has a problem, put a note and suggest a course of action. 

PHP 7 Compatibility Checker

php7cc is another similar tool for compatibility checking. It will show errors in red, which could be fatal, syntax, or notices. It will also display warnings in yellow. 


php7aid is showing directly what part of your PHP 5 code won’t work. It will try to help you resolve the problems. 

Updating PHP 5 to PHP 7 on Linux

In this step-by-step guide, we will update PHP 5 to PHP 7 on an Ubuntu computer running LEMP (Linux, Nginx, Mysql, PHP) and a user with sudo permissions. 

Before installing or updating, we need to add the repository, which contains PHP 7 for Ubuntu. Use the following command:

sudo add-apt-repository ppa:ondrej/php 

The Terminal will show you a description of the repository. Press Enter and continue. 

Then you will need to check for updates with this command:

sudo apt-get update

 Finally, we can install PHP 7 with the following command:

sudo apt-get install php7.0-fpm php7.0-mysql 

After the installation of the PHP 7, change the path to the fastcgi_pass to the new PHP 7. You need to change “/var/run/php5-fpm.sock” to “/var/run/php/php7.0-fpm.sock”. The result should look like this:

location ~ \.php$ {

 try_files $uri =404;

 fastcgi_split_path_info ^(.+\.php)(/.+)$;

 fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

 fastcgi_index index.php;

 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

 include fastcgi_params;


Now that we are ready, restart the Nginx:

sudo service nginx restart 


Updating PHP 5 to PHP 7 on macOS

To update PHP 5 to 7 on macOS, we are going to use Homebrew. If you don’t have Homebrew installed already, you can follow these steps to get it. 

Open the Terminal application. 

Paste the following command onto the Terminal and press Enter: 

/bin/bash -c “$(curl -fsSL” 

Press Enter again to agree and then enter your username and password. 

Now you are ready to use Homebrew.

Again, inside the Terminal, you will need to use a few commands:

brew install openldap libiconv

brew tap exolnet/homebrew-deprecated

brew unlink php56

brew install [email protected]

There are no older versions left inside Homebrew’s repositories, so here we are installing directly PHP 7.4 that is still available. In this case, we have unlinked an older version PHP 5.6, before installing the new one. If you have another previous version, you can unlink it. 

Updating PHP 5 to PHP 7 on Windows

If you are a Windows user and you are using XAMPP or WAMP, just update your software. The newer version will have the latest PHP version. You can also go to their websites and download the right version for you. There you can see with which PHP version they are coming before downloading and installing them. 

Updating on CentOS, Fedora, Red Hat

For those of you running any of these OSes, you will need to follow these commands: 

sudo yum update

rpm – Uvh

rpm – Uvh

sudo yum install php70w

sudo yum install php70w-mysql

Consider updating from PHP 5 to PHP 8 directly. 

There will be support for PHP 7.3 until 06.12.2021 and PHP 7.4 until 28.11.2022. Consider making the jump directly to PHP 8 so you can get the newest features and longer support. 

bookmark_borderWhat is the difference between PHP 5 and PHP 7?

The Hypertext Preprocessor (PHP) is a very popular scripting language. It’s been a standard since 1994 due to its attractive features. Safer connectivity to the database, faster speed, runs smoothly on the most used platforms (Windows, Unix, Linux). Of course, there were many improvements, but let’s have a closer look at PHP 5 and PHP 7.

PHP 5 main features.

PHP5 was developed considerably more robust than PHP 4. The Zend II engine powered it. It offered an improved mechanism for handling exceptions and errors, a model oriented to objects that supplies interfaces, abstract classes, constructors, static and final properties. Besides, it had SSL connections, multi-query functions for MySQL extension. PHP5’s XML extensions were enhanced, just like the soap implementation for providing and consuming web services, speed, and performance.

PHP 7 main features.

PHP 7 was the successor of PHP 5. Its performance was better than the PHP 5. It was powered by a PHP-NG (Next Generation) engine. It achieved twice the PHP 5 performance and 50% less memory consumption to give a reference. It added anonymous classes, removal of deprecated methods, better exception hierarchy and handling, more efficient memory use, abstract syntax tree, and support for return type declarations. Besides, it included scalar type declarations for better controlling the code, CSPRNG functions, spaceship operator (three-way comparison), constant arrays using define (). 

What is the difference between PHP 5 and PHP 7?

  • Performance. And PHP 7 speed got double than the one offered by PHP 5. While PHP 5 (Zend II engine) handled an average of 22 requests per second, PHP 7 (PHP-NG engine) made 44. So PHP 7 totally boosted the scripting performance and websites’ loading speed.
  • Exception handling. Handling fatal errors with PHP 5 was hard for developers, mostly because errors were not displayed directly. You needed to trace the information to find it and to identify if it was fatal or not for an application. On PHP 7, important errors became exceptions to be caught easier.
  • Return type. PHP5 didn’t include a provision for return type declarations. This feature was added to PHP 7 version, making the code more accurate. The available return types were: float, string, bool, int.
  • Null coalescing operator ?? On PHP 5, you had to write explicit code to return the null value in the case the value was not available (it didn’t exist). On PHP 7, you could just use the operator ?? (two question marks) to return a variable’s value if it was available or for returning null if it was not available.
  • Spaceship operator (combined or three-way comparison). With PHP 5, many different operators were used for comparing. PHP 7 integrated the three-way comparison operator (<=>), meaning that with a single operator, three kinds of comparisons were possible to do simultaneously: greater than, less than, and equal. It returned 0, meaning equal, -1 if the right part was greater than the left, and 1 in the opposite scenario.
  • Declarations. PHP 5 worked with individual declarations for namespaces. PHP 7 simplified the task through the use of group declaration. This made code more compact and easy to read. It definitely meant less time typing for programmers. 
  • 64-bit support. While PHP5 didn’t support 64-bit, PHP7 did, the complete 64-bit and large files. Running applications smoothly on these architectures was not a problem anymore.
  • Anonymous class. It was included on PHP 7. Then, creating a complete definition of a class required just once in the whole application was not needed anymore. Instead, an anonymous class for a single-use got possible. 


The jump from PHP 5 to PHP 7 was key for PHP to evolve and become a more useful scripting language. Currently, we are on PHP 8 (8.0.8 version). Stop imagining the possibilities. Better experience them now!

bookmark_borderPHP 7 explained

PHP 7 explained

PHP 7 is a significant release of PHP programming language. It is promoted as a revolution. As for how web applications are possible to be developed and produced for the cloud and mobile to enterprises. This particular release is pointed to be the most significant improvement for PHP after the announcement of PHP 5 in 2004. 

Initiation of the development of PHP 7

The initiative for the development of PHP 7 came from Dmitry Stogov, Xinchen Hui, and Nikita Popov. These three developers designed a test branch of PHP that they first named PHP Next Generation (PHPNG). The PHP community embraced it, as it had crucial performance improvements. It continued to develop into a well-built version now known as PHP 7. After some months of beta testing, the official release was in December 2015.

What Drove the Need for PHP 7?

The PHP language is extremely popular. Rasmus Lerdorf created it in 1994. Since then, it has gained popularity, and now approximately 82 percent of websites implement PHP. That indicates that most of the Web is relying on this language. In addition, the amount of people online is continuing to increase. This includes the rapidly growing number of mobile users. Therefore, the servers that power the world’s websites are necessary to be able to respond fast to user requests. Speed is an essential factor in the design of a website. People are going to leave a web page that takes a lot of time to load. 

The PHP changes boosted the performance of sites dramatically. It is estimated that version 7 gives a 100 percent increase in performance speed compared to version 5.6. This allows the developers to make websites that present attractive and interesting interactive traits that can also respond to visitors’ input fast. 

The development of this version was also motivated by the need for scripting languages that work more efficiently. The desire for that is inspired by two things: the need to decrease power consumption to protect the ecosystem and the need to reduce expenses.

It reduces the demands on the servers, which makes it more friendly for the environment and more cost-effective decision. In addition, compared to PHP 5.6, running PHP 7 applications needs less energy to power servers.

New Features

To PHP 7 are added a lot of new features. The most significant ones from them are the following: 

  • Improved performance − It is twice faster than PHP 5 when you have a PHPNG code united in PHP 7.
  • Scalar type declarations − Now, return types and parameters are able to be implemented.
  • Less Memory Usage − The optimized PHP 7 consumes a lot lesser resources.
  • Exception hierarchy − The feature is improved.
  • 64-bit support − 64-bit architecture machines receive constant support.
  • Several fatal errors converted to Exceptions − The variety of exceptions is extended. Including many fatal errors turned into exceptions.
  • Null coalescing operator (??) − A new feature is applied to replace the ternary operation in conjunction with the isset() function.
  • Secure random number generator − Increase of the latest secure random number generator API.
  • Return and Scalar Type Declarations − Added support for the return type and parameter type.
  • Deprecated SAPIs and extensions removed − Several past and unsupported SAPIs and extensions are eliminated from the PHP 7 version.
  • Anonymous Classes − It is added support for anonymous.
  • Zero cost asserts − Also added support for zero cost asserts.

PHP 7 applies new Zend Engine 3.0. The purpose is for the performance of the application to improve twice. Also, the consumption of memory to be 50% better than PHP 5.6. This allows without any extra hardware to work for more concurrent users.

PHP 7 is created contemplating today’s workloads.