Bug #79960 [Opn->Nab]: json_encode(JSON_NUMERIC_CHECK) works differently between 5.4.x and 7.x
| From: | cmb@php.net | Date: | Wed, 12 Aug 2020 10:00:28 +0000 |
| Subject: | Bug #79960 [Opn->Nab]: json_encode(JSON_NUMERIC_CHECK) works differently between 5.4.x and 7.x | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-228536@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79960&edit=1
ID: 79960
Updated by: cmb@php.net
Reported by: danny at klarity dot tv
Summary: json_encode(JSON_NUMERIC_CHECK) works differently
between 5.4.x and 7.x
-Status: Open
+Status: Not a bug
Type: Bug
Package: JSON related
Operating System: Centos 8
PHP Version: 7.2.33
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is because hexadecimal strings are no longer considered
numeric as of PHP 7.0.0[1].
[1] <https://www.php.net/manual/en/migration70.incompatible.php#migration70.incompatible.strings.hex>
Previous Comments:
------------------------------------------------------------------------
[2020-08-12 09:54:21] danny at klarity dot tv
Description:
------------
After upgrading from PHP 5.4 to 7.2 (with OS upgrade) the behavior of json_encode with
JSON_NUMERIC_CHECK changed.
In 5.4, a hex string was converted to an int.
In 7.2, a hex string is output as a hex string.
Test script:
---------------
$ php --version
PHP 5.4.45 (cli) (built: Oct 16 2015 11:02:47)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
$ php --interactive
php > print(json_encode("0xFF", JSON_NUMERIC_CHECK));
255
$ php --version
PHP 7.2.11 (cli) (built: Oct 9 2018 15:09:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
$ php --interactive
Interactive shell
php > print(json_encode("0xFF", JSON_NUMERIC_CHECK));
"0xFF"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79960&edit=1