Home > Article > Backend Development > Little things you have to know about php7
It has been a long time since PHP7 was officially released. When it first came out, it was said to be several times faster than the old version. The speed and efficiency of various open source frameworks or systems running on PHP7 have increased several times. Anyway, whether it is the media or developers They are all fanning the flames, no, they should be full of praise.
Generally, I am the last one to upgrade mobile phone systems because I don’t want to step into the trap. After all, iOS and Android systems will have bugs, not to mention the most hacked ones in the world. language.
The time has come today, and Sister Yuan will start to give you some popular science about PHP7.
1. The new Zend engine
The Zend engine has been driving PHP since php4 in 1999. Zend (not to be confused with zend framework) is an open source engine developed in C language. The current version of php 5.X uses the Zend II version, which has important performance improvements for php. Php7 will use a new engine called PHPNG to drive
2. More convenient error handling
Catching and handling errors has never been an easy task for PHP programmers. The new engine will allow you to use exceptions instead of errors. Just like in the php5.X version, in php7 if The exception is not caught,
php will return an error.
\EngineException object does not inherit\Exception, which ensures the backward compatibility of the code and two different types of exceptions in error handling Handling: Traditional and new engine exception handling.
In order to facilitate us to catch two exceptions, php7 has introduced the following new exception handling methods:
3. Support for 64-bit windows operating systems
php is a member of LAMP, which means that its native environment is Linux-but it can also run on windows operating systems. Version 5.X is still available It does not support 64-bit shaping or large files, so Windows with the X64 series architecture is still experimental.
php7 will support 64-bit windows, which also means that 64-bit shaping and large files will be Support
4. Scalar type declaration
Scalar type declaration has two modes: mandatory (default) and strict mode. The following type parameters are now available (either in forced or strict mode): string, int, float, and bool. They extend other types introduced in PHP5: class names, interfaces, arrays and callback types.
The above routine will output:
To use strict mode, a declare declaration directive must be placed at the end of the file top. This means that scalars are strictly declared configurable on a file basis. This directive affects not only the type declaration of parameters, but also the return value declaration of functions (see Return value type declaration, built-in PHP functions and PHP functions loaded in extensions)
5. Argon2 in password hashing
Argon2 is a powerful hashing algorithm that won the 2015 Password Hash Algorithm Competition. PHP 7.2 uses it as a secure replacement for the Bcrypt algorithm.
The new version of PHP has introduced the PASSWORD_ARGON2I constant, which can now be used in the password_* series of functions:
password_hash('password', PASSWORD_ARGON2I);
Unlike Bcrypt, which only uses one cost factor, Argon2 uses three cost factors. The distinction is as follows :
Defines the amount of KiB memory overhead that should be consumed during hash calculation (default value is 1
Defines the number of iterations of the hash algorithm Time overhead (default value is 2)
Parallel factor, used to set the number of parallel threads used in hash calculation (default value is 2)
The following three new constants define the default The cost factor:
PASSWORD_ARGON2_DEFAULT_MEMORY_COST
PASSWORD_ARGON2_DEFAULT_TIME_COST
PASSWORD_ARGON2_DEFAULT_THREADS
But why does Sister Yuan come to discuss PHP7 this time?
Because Sister Yuan received a huge news before
There are still two months to stop PHP 5.6 security support!
According to the supported versions and schedule listed on the PHP official website (below), PHP 5.6 security support will terminate on December 31, 2018. That is, after two and a half months, websites using PHP version 5.6 will no longer receive updates for security vulnerabilities or errors.
Scott Arciszewski, chief development officer of Paragon Initiative Enterprise, said in an interview that
This is a huge problem for the PHP ecosystem. Many people think they can 'get away' with running PHP 5 in 2019, but this is actually a deliberate oversight of security.
In fact, the major and security update period of PHP 5.6 has ended long ago, but due to the large number of websites used, the PHP maintenance organization once extended its support time respectively. Some people describe this situation as a PHP risk. The newer PHP 7.0 will no longer provide security support at EOL (End of Life) on December 1, 2018. Even version PHP 7.1 will be discontinued on December 1, 2018. Security support ends after one year.
Among the three major website content management system (CMS) projects, only Drupal announced that starting from March 6, 2019, Drupal will support the minimum requirement of PHP 7 for web pages, and it is recommended to use version 7.1. Joomla recommends version 5.6 or higher, with support starting at 5.3.10. Wordpress recommends PHP 7.2 or higher, with a minimum of 5.2.4 supported.
According to ZDNet, WordFence security component R&D director Sean Murphy said that the main target of PHP vulnerability exploitation is not in PHP itself, but in the PHP library and CMS system, but other security experts believe that when the deadline comes , hackers will actively exploit the vulnerabilities in PHP 5.6.
The main target of PHP vulnerability attackers is not PHP itself, but the PHP function library and CMS system. When the two-month deadline comes, hackers will be more active in finding vulnerabilities in versions prior to PHP 5.6. My own website was accidentally hacked, and the website became a pornographic and gambling website, and its image plummeted!
Recommended learning: php video tutorial
The above is the detailed content of Little things you have to know about php7. For more information, please follow other related articles on the PHP Chinese website!