PHP 7 is coming – everything you need to know

Home  >>  Geek Stuff  >>  PHP 7 is coming – everything you need to know

PHP 7 is coming – everything you need to know

23
Jun,2015

2

The upcoming stable release of PHP 7.0.0 will be available within just a few months. This new version is expected to bring a lot of positive changes for the users of the well-known programming language and also include core changes to its architecture.

Performance of web applications under PHP 7 will thus be improved without needing to change a single line of PHP code. Their users will only have to switch to the newest version of the popular scripting language to take advantage of these improvements.

Some notes about PHP 6 and why 5+1 = 7

Most probably you are wondering what happened to PHP 6 and why the next version number of PHP will start directly with 7.

PHP 6 was an attempt of the creators of the language to bring forth Unicode support. This is one of the most frequently requested features to be added to the scripting language.

As you probably know unicode is a standard for encoding, representation and handling of text expressed in most of the world’s writing systems. Adding support for it will help improve the representation of text in various ways. It will help the proper display of symbols from various alphabets and avoid mojibake.

Mojibake

  noun: phenomenon of incorrect, unreadable characters shown when computer software fails to render a text correctly according to its associated   character encoding

The project however was discontinued because new features were delayed and opinions were varying amongst core PHP developers about Unicode implementation.

PHP-NG and the new engine behind PHP 7

Zend Engine is the main scripting engine behind PHP. I will try to explain its purpose without getting into unnecessary details and technicalities.

The PHP programming language itself is created in the C language. The creators of the Zend Engine were influenced by Java and created a virtual machine on which the language is executed. You can think of it as of a virtual processor with its own instructions, designed solely for executing PHP programs.

The creators and maintainers of the PHP programming language from Zend Technologies have decided to improve the scripting engine behind PHP.

And here comes PHP-NG as the base for the latest release of the language. It is a revised version of Zend Engine with performance and memory usage improvements. In fact , according to the Zend team and the benchmarks they performed, PHP 7 is expected to speed up different applications with up to 100%. Their tests included the most popular CMS , CRM and E-commerce apps ( including some of our favorites WordPress , Drupal , SugarCRM and Magento ) as well as two of the most popular frameworks today Laravel and Zend Framework. And the results are simply amazing and the expectations of the impact that this release will have on the Internet world are highly raised.

There’s also an official Vagrant PHP 7 test box from Rasmus Lerdof (one of the developers behind the initial version of the language). You can clone the repository from GitHub,  then download it and use it with VirtualBox on your local workstation with Vagrant.

Some of the new features introduced with the PHP 7 syntax

When building the new PHP 7 I noticed a message concerning the mysql extension. A warning appeared about an unexisting ‘mysql’ module. That leads me to believe that the mysql module might be deprecated in favour of mysqli (MySQL improved).

The POSIX compatible regular expressions extension is also going to be deprecated. The Perl Compatible Regular Expressions support will however remain.

//The language’s object-oriented capabilities are going to be taken to the next level.

The Unicode Control character (u) will be now available giving us the opportunity to convert hexidemical values to their respective unicode characters:

echo “u{0041}”;

For example this will output a capital “A”.

Scalar type hinting will be introduced as well. Types of function parameters and the values a function should return can now be declared.

            function scalar ($data) : array {
                        return json_encode($data);
            }

The combined comparison operator (otherwise known as the spaceship operator) will also be presented . It can be used for all data types, not just strings like when using strcmp() or version_compare().

          function order ($a, $b) {
                       return $a <=> $b;
            }

In this example the function order will return -1 if $a is smaller than $b, 0 if they are equal and 1 if $a is bigger than $b.

Another important change is that the PHP 7 use statement has been extended and it will provide us with a more comfortable syntax to use multiple classes from the same namespace. Until PHP 5.6 the following syntax was needed:

use AppClasseesComponentsSubComponentJsonAPI;
use AppClasseesComponentsSubComponentSmtpClient;
use AppClasseesComponentsSubComponentRESTful;

While only the following will do the same job for you in the latest version of PHP:

use AppClasseesComponentsSubComponent{
            JsonAPI, SmtpClient, RESTful
};

In addition new classes for easier handling of parse errors of PHP code evaluated with the eval() function and engine exceptions are added to PHP 7. Those classes are the following:

EngineException
BaseException
ParseException

As you have probably already sensed we are highly anticipating this new release of one of the programming languages that’s powering the majority of websites on the World Wide Web. PHP7 would revolutionize the way the popular scripting language works under the hood and improve the experience of your websites’ visitors!

The newest PHP 7 will be available for all WebHostFace users through the custom PHP tools as soon as the stable version is released. They’ll be able to switch the language version with a single click when our shared servers are provisioned with the latest stable version. So keep your ears sharp – we will let you know as soon as PHP 7 is officially released and in the meantime you can share your own expectation in the comments below.

was this blog post useful to you

Always willing to learn new concepts and skills not only in the area of Internet and computers. During his free time you can find him reading books on various topics and styles, at a concert, watching a flick from one of his favorite directors or travelling to different places (sometimes even hitchhiking).



2 Comments so far:

  1. Cvetomir, please put that knowledge to good use and help me out.
    I am learning Ruby on Rails, and I have produced a small app. The tutorial had me host it on Heroku. How do I host RoR on WebHostFace? I have read about the subject, but still don’t get why it’s easy to host WordPress and php, but not RoR, What am I missing?
    Thanks.
    Alan

    • Hey there Alan, the option to set up a Ruby app on our shared environment is disabled by default and we enable it per account after a request. I checked and enabled it for you, you can now use the new Setup Ruby App button in your cPanel to manage RoR for your hosting account. If you have any other questions, feel free to contact us on our Live Chat, phone or via email as we would be able to help you more quickly through them.

Leave a Comment:

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