xref: /PHP-7.4/ext/json/tests/bug42785.phpt (revision 21f049b4)
1--TEST--
2Bug #42785 (Incorrect formatting of double values with non-english locales)
3--INI--
4serialize_precision=-1
5--SKIPIF--
6<?php
7if (!extension_loaded('json')) die('skip');
8if (!setlocale(LC_CTYPE, "de_DE", "de", "german", "ge", "de_DE.ISO8859-1", "ISO8859-1")) {
9	die("skip locale needed for this test is not supported on this platform");
10}
11?>
12--FILE--
13<?php
14setlocale(LC_ALL, "de_DE", "de", "german", "ge", "de_DE.ISO8859-1", "ISO8859-1");
15
16$foo = array(100.10,"bar");
17var_dump(json_encode($foo));
18
19class bar {}
20$bar1 = new bar;
21$bar1->a = 100.10;
22$bar1->b = "foo";
23var_dump(json_encode($bar1));
24?>
25--EXPECT--
26string(13) "[100.1,"bar"]"
27string(21) "{"a":100.1,"b":"foo"}"
28