PHP 7: what's new and when will it be released?

Web development is one of the most important areas in programming. And every developer who works in this field and considers himself a real programmer is familiar with a language such as PHP. This programming language has long been successfully used worldwide for the development of sites and web applications. And if earlier development was carried out on the fifth version of the language, now everyone is switching to PHP 7. The release date for the new version is June 11, 2015. It is worth noting that this is only an alpha version. The final is scheduled for the end of 2015.

Innovations

php 7

So, what's new in the latest version of the language? The developers have made the following changes and additions:

  • The performance of PHP 7 is doubled compared to previous versions.
  • 64-bit architecture will be supported.
  • A large number of fatal errors turned into exceptions.
  • A combined operator appeared to compare values.
  • A shorthand use construct is supported.
  • An operator has been added that checks the variable for its existence and returns a value.
  • It has become possible to specify arrays as constant values, which are declared using define.
  • The syntax of the constructors from the fourth version is now deprecated.
  • PHP 7 added anonymous classes.

This is a short list of changes. Next will be discussed in detail the improvements and innovations of the language. Surprisingly, 10 years have passed from the fifth version to the seventh.

Why was there no PHP 6 after PHP 5?

php 7 what's new

For many, this is a mystery. In fact, everything is simple. The release of the Six simply did not take place. Its main feature was support for Unicode characters, since in web development without this, nowhere.

The idea was to implement this support in the core of PHP 7. What would it give? Enhanced language capabilities, of course. It would be possible to use smiles as identifiers, as well as expand the functionality of strings in various languages.

These plans were ambitious, but there were a large number of problems. It was very difficult and tedious to port a huge part of the code in order to support Unicode. This influenced the development of other features and frustrated web developers. So, over time, interest in Unicode support began to decline, and the sixth version was no longer developed.

But all this has already become history since the PHP 7 version was released. What's new in it?

Performance improvement

php 7 general-purpose scripting language

Previously, all updates improved performance slightly, and for developers the main goal was a significant shift in PHP 7 for the better. They were able to handle it. Now the interest of programmers in the Zend engine, on which the PHP language is based, has increased several times. Many experts noted that the new version has evolved significantly and become competitive. After all, other scripting programming languages began to gain leadership.

Just In Time Engine

php 7 release date

The development of PHP 7 began with a study that allows you to learn more about the implementation of this engine, which is able to compile code into machine dynamically. After all, this allows you to several times increase the speed of the code during its execution. Although the full implementation has not yet occurred, but the creators are actively experimenting with this. If they manage to introduce a JIT engine into the language, this will allow them to raise the ultimate level of performance even higher.

Abstract syntax tree

install php 7 on linux

This compilation step was proposed by a Russian programmer. The tree is able to provide several advantages, including a great potential for future optimization and more efficient memory allocation, which will speed up the work of PHP 7. Thus, the possibilities of opening the tree in user applications have been described. This can lead to the emergence of high-quality tools that will be extremely useful in finding errors. Tests that were run on real applications showed that the new version uses half as much memory at the time of request processing. Despite the fact that everything in the new version looks pretty familiar, it is very different from the previous one in terms of performance. After all, the fact that less memory is consumed enables low-power machines to process requests faster. And this helps build a kind of microservices around PHP.

Asynchronous programming

how to install php 7

In PHP 7, this is a necessary step in order to implement an event loop. This is the part of the code that intercepts events related to input and output, as well as other tasks of the asynchronous type that can work in parallel (access to the network, files, databases).

Simply put, this will provide an opportunity to add support for performing such tasks within a single request. Asynchronous programming will also allow several times to increase productivity.

Improved syntax

PHP 7 is a general-purpose scripting language. And the syntax has been improved for writing these scripts. Now the code has become easier to write, it looks more pleasant for developers. What has been changed?

  • Now you can group import declarations of those classes that are on the same line and in a single namespace. This helps save a few bytes in the code.
  • Adding a Null-coalescent operator solves the problem when a programmer wants to assign a value to a variable already assigned to another variable.
  • The combined comparison operator, which is called the “spaceship,” helps to make a three-level comparison of a pair of values. It allows us to understand not only the equality of these values ​​or their inequality, but also which of the values ​​is greater if they are not equal.

Exceptions

If earlier fatal errors led to a complete stop of the executed script, then with the appearance of exceptions, they are caught and processed. Now errors such as calling a nonexistent function will not stop the script. An exception is thrown that can be handled in a separate code block. This is an important feature for servers, as fatal errors can lead to the need for a reboot, which greatly slows down the work.

How to install PHP 7

1. You need to download the latest version from the official site.

2. From the archive, the contents are extracted to the php folder. No installation is required.

3. The server configuration file is changed (meaning Apache).

4. The DirectoryIndex parameter must be changed to index.html.

5. The server reboots, and then through the browser go to the index.php page and make sure that everything works as it should.

In principle, the process has not changed much compared to the previous version. Installing PHP 7 on Linux is slightly different, since you need to download packages from the repositories, and then install using special commands.

Conclusion

Of course, all the latest changes to the PHP programming language have become significant. Most of them were made due to competition with Facebook and its Hack programming language, which began to take over the lead. This is what gave impetus to development. You can thank Mark Zuckerberg and his company for this. After all, it has brought great benefits to the community of PHP developers. Now web development has reached a whole new level. Productivity has been increased and will continue to grow, and therefore, competition with other scripting programming languages ​​will be maintained for now. After all, they still have a long way to move the giant PHP from their place.

Source: https://habr.com/ru/post/K23032/


All Articles