The PHP version was recently upgraded from 7.1 to 7.2. Version before upgrade:
PHP 7.1.14 (cli) (built: Feb 2 2018 08:42:59) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.1.14, Copyright (c) 1999-2018, by Zend Technologies with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
Version after upgrade:
PHP 7.2.2 (cli) (built: Feb 24 2018 17:51:12) ( ZTS DEBUG ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.2, Copyright (c) 1999-2018, by Zend Technologies
Recommended (Free):PHP7
After the upgrade, I found that several frameworks had problems when using them. The main reason was that some functions were abandoned after 7.2, which are listed below Several common problems:
1. Each function has been abandoned:
Previous version writing:
Copy after login
will prompt that it is outdated in version 7.2 , you can use foreach instead of each method, or you can modify each method yourself instead:
Copy after login
2. When an invalid parameter is passed, the count() function will throw a warning warning:
Previous version writing
Copy after login
In version 7.2, type distinction will be strictly enforced. If the parameter type is incorrect, a warning will appear, so you need to pay attention to the value of the parameter when using the count method, but you can also pass Modify your own method to replace it (not recommended):
Copy after login
3. create_function is abandoned and can be replaced by an anonymous function:
Previous version writing:
Copy after login
There will be a warning prompt in version 7.2, which can be modified to an anonymous function instead:
Copy after login
The above are a few problems temporarily encountered after the upgrade. For other related modifications, please see the Lianjia product technical team for details. Translation and organization: PHP7.2 version guide
The above is the detailed content of Summary of things you need to pay attention to after upgrading PHP to 7.2. For more information, please follow other related articles on the PHP Chinese website!