1--TEST--
2Test that floats are converted to string locale independently
3--SKIPIF--
4<?php
5
6if (!setlocale
7    (LC_ALL,
8    "german", "de", "de_DE", "de_DE.ISO8859-1", "de_DE.ISO_8859-1", "de_DE.UTF-8",
9    "french", "fr", "fr_FR", "fr_FR.ISO8859-1", "fr_FR.ISO_8859-1", "fr_FR.UTF-8",
10    )) {
11    die("skip - locale needed for this test is not supported on this platform");
12}
13
14?>
15--FILE--
16<?php
17
18function print_float(float $f)
19{
20    echo "- casting:\n";
21    echo $f . "\n";
22    echo strval($f) . "\n";
23    $g = $f;
24    settype($g, "string");
25    echo $g . "\n";
26
27    echo "- *printf functions:\n";
28    printf("%.2f\n", $f);
29    printf("%.2F\n", $f);
30    echo sprintf("%.2f", $f) . "\n";
31    echo sprintf("%.2F", $f) . "\n";
32
33    echo "- export/import:\n";
34    echo var_export($f, true)  . "\n";
35    echo serialize($f) . "\n";
36    echo json_encode($f) . "\n";
37
38    echo "- debugging:\n";
39    echo print_r($f, true) . "\n";
40    var_dump($f);
41    debug_zval_dump($f);
42
43    echo "- other:\n";
44    echo implode([$f]) . "\n";
45}
46
47setlocale(LC_ALL, "C");
48echo "C locale:\n";
49
50print_float(3.14);
51
52setlocale(
53    LC_ALL,
54    "german", "de", "de_DE", "de_DE.ISO8859-1", "de_DE.ISO_8859-1", "de_DE.UTF-8",
55    "french", "fr", "fr_FR", "fr_FR.ISO8859-1", "fr_FR.ISO_8859-1", "fr_FR.UTF-8",
56);
57echo "\nde_DE locale:\n";
58
59print_float(3.14);
60
61?>
62--EXPECT--
63C locale:
64- casting:
653.14
663.14
673.14
68- *printf functions:
693.14
703.14
713.14
723.14
73- export/import:
743.14
75d:3.14;
763.14
77- debugging:
783.14
79float(3.14)
80float(3.14)
81- other:
823.14
83
84de_DE locale:
85- casting:
863.14
873.14
883.14
89- *printf functions:
903,14
913.14
923,14
933.14
94- export/import:
953.14
96d:3.14;
973.14
98- debugging:
993.14
100float(3.14)
101float(3.14)
102- other:
1033.14
104