Home Backend Development PHP7 Little things you have to know about php7

Little things you have to know about php7

Aug 06, 2021 pm 05:36 PM
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.

Little things you have to know about php7

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:

Little things you have to know about php7

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.

Little things you have to know about php7

The above routine will output:

Little things you have to know about php7

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);
Copy after login

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.

Little things you have to know about php7

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to install mongo extension in php7.0 How to install mongo extension in php7.0 Nov 21, 2022 am 10:25 AM

How to install the mongo extension in php7.0: 1. Create the mongodb user group and user; 2. Download the mongodb source code package and place the source code package in the "/usr/local/src/" directory; 3. Enter "src/" directory; 4. Unzip the source code package; 5. Create the mongodb file directory; 6. Copy the files to the "mongodb/" directory; 7. Create the mongodb configuration file and modify the configuration.

How to solve the problem when php7 detects that the tcp port is not working How to solve the problem when php7 detects that the tcp port is not working Mar 22, 2023 am 09:30 AM

In php5, we can use the fsockopen() function to detect the TCP port. This function can be used to open a network connection and perform some network communication. But in php7, the fsockopen() function may encounter some problems, such as being unable to open the port, unable to connect to the server, etc. In order to solve this problem, we can use the socket_create() function and socket_connect() function to detect the TCP port.

What should I do if the plug-in is installed in php7.0 but it still shows that it is not installed? What should I do if the plug-in is installed in php7.0 but it still shows that it is not installed? Apr 02, 2024 pm 07:39 PM

To resolve the plugin not showing installed issue in PHP 7.0: Check the plugin configuration and enable the plugin. Restart PHP to apply configuration changes. Check the plugin file permissions to make sure they are correct. Install missing dependencies to ensure the plugin functions properly. If all other steps fail, rebuild PHP. Other possible causes include incompatible plugin versions, loading the wrong version, or PHP configuration issues.

How to install and deploy php7.0 How to install and deploy php7.0 Nov 30, 2022 am 09:56 AM

How to install and deploy php7.0: 1. Go to the PHP official website to download the installation version corresponding to the local system; 2. Extract the downloaded zip file to the specified directory; 3. Open the command line window and go to the "E:\php7" directory Just run the "php -v" command.

PHP Server Environment FAQ Guide: Quickly Solve Common Problems PHP Server Environment FAQ Guide: Quickly Solve Common Problems Apr 09, 2024 pm 01:33 PM

Common solutions for PHP server environments include ensuring that the correct PHP version is installed and that relevant files have been copied to the module directory. Disable SELinux temporarily or permanently. Check and configure PHP.ini to ensure that necessary extensions have been added and set up correctly. Start or restart the PHP-FPM service. Check the DNS settings for resolution issues.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Apr 01, 2025 pm 03:06 PM

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

Which one is better, php8 or php7? Which one is better, php8 or php7? Nov 16, 2023 pm 03:09 PM

Compared with PHP7, PHP8 has some advantages and improvements in terms of performance, new features and syntax improvements, type system, error handling and extensions. However, choosing which version to use depends on your specific needs and project circumstances. Detailed introduction: 1. Performance improvement, PHP8 introduces the Just-in-Time (JIT) compiler, which can improve the execution speed of the code; 2. New features and syntax improvements, PHP8 supports the declaration of named parameters and optional parameters, making functions Calling is more flexible; anonymous classes, type declarations of properties, etc. are introduced.

See all articles