mirror of
https://github.com/php/php-src.git
synced 2026-04-24 00:18:23 +02:00
717f1ed5e4
Encoding a negative zero as `-0` is likely to loose the sign when decoding (at least it does with `json_decode()`). Therefore, we encode it as if `JSON_PRESERVE_ZERO_FRACTION` was specified, i.e. as `-0.0`. Closes GH-7234.
13 lines
230 B
PHP
13 lines
230 B
PHP
--TEST--
|
|
Bug #79908 (json_encode encodes negative zero as int)
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded('json')) die("skip json extension not available");
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
var_dump(json_encode(-0.));
|
|
?>
|
|
--EXPECT--
|
|
string(4) "-0.0"
|