Bug #79960 [NEW]: json_encode(JSON_NUMERIC_CHECK) works differently between 5.4.x and 7.x

From: Date: Wed, 12 Aug 2020 09:54:21 +0000
Subject: Bug #79960 [NEW]: json_encode(JSON_NUMERIC_CHECK) works differently between 5.4.x and 7.x
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228535@lists.php.net to get a copy of this message
From: danny at klarity dot tv Operating system: Centos 8 PHP version: 7.2.33 Package: JSON related Bug Type: Bug Bug description:json_encode(JSON_NUMERIC_CHECK) works differently between 5.4.x and 7.x 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 bug report at https://bugs.php.net/bug.php?id=79960&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79960&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79960&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79960&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79960&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79960&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79960&r=support Expected behavior: https://bugs.php.net/fix.php?id=79960&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79960&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79960&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79960&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79960&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79960&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79960&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79960&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79960&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79960&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79960&r=mysqlcfg

« previous php.bugs (#228535) next »