PHP 7.1 and number check
+
+
Par Remi le samedi 11 juin 2016, 09:40 - Développement - Lien permanent
PHP 7.1 introduce a new check during conversion of string to number.
Example :
$ module load php70 $ php -v PHP 7.0.8RC1 (cli) (built: Jun 8 2016 06:25:44) ( NTS ) $ php -r 'var_dump("1K" * 1024);' int(1024) $ module load php71 $ php -v PHP 7.1.0alpha1 (cli) (built: Jun 8 2016 09:36:05) ( NTS ) $ php -r 'var_dump("1K" * 1024);' PHP Notice: A non well formed numeric value encountered in Command line code on line 1 int(1024)
See it on 3v4l.org.
It is obvious that this new message is useful, but such code is very common.
Some examples in real projects:
You can start checking your code ;)
Commentaires
For memory, see the PHP RFC: Warn about invalid strings in arithmetic