1--TEST-- 2Test that floats are converted to string locale independently 3--SKIPIF-- 4<?php 5if (setlocale(LC_ALL, 'invalid') === 'invalid') { die('skip setlocale() is broken /w musl'); } 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--FILE-- 15<?php 16 17function print_float(float $f) 18{ 19 echo "- casting:\n"; 20 echo $f . "\n"; 21 echo strval($f) . "\n"; 22 $g = $f; 23 settype($g, "string"); 24 echo $g . "\n"; 25 26 echo "- *printf functions:\n"; 27 printf("%.2f\n", $f); 28 printf("%.2F\n", $f); 29 echo sprintf("%.2f", $f) . "\n"; 30 echo sprintf("%.2F", $f) . "\n"; 31 32 echo "- export/import:\n"; 33 echo var_export($f, true) . "\n"; 34 echo serialize($f) . "\n"; 35 echo json_encode($f) . "\n"; 36 37 echo "- debugging:\n"; 38 echo print_r($f, true) . "\n"; 39 var_dump($f); 40 debug_zval_dump($f); 41 42 echo "- other:\n"; 43 echo implode([$f]) . "\n"; 44} 45 46setlocale(LC_ALL, "C"); 47echo "C locale:\n"; 48 49print_float(3.14); 50 51setlocale( 52 LC_ALL, 53 "german", "de", "de_DE", "de_DE.ISO8859-1", "de_DE.ISO_8859-1", "de_DE.UTF-8", 54 "french", "fr", "fr_FR", "fr_FR.ISO8859-1", "fr_FR.ISO_8859-1", "fr_FR.UTF-8", 55); 56echo "\nde_DE locale:\n"; 57 58print_float(3.14); 59 60?> 61--EXPECT-- 62C locale: 63- casting: 643.14 653.14 663.14 67- *printf functions: 683.14 693.14 703.14 713.14 72- export/import: 733.14 74d:3.14; 753.14 76- debugging: 773.14 78float(3.14) 79float(3.14) 80- other: 813.14 82 83de_DE locale: 84- casting: 853.14 863.14 873.14 88- *printf functions: 893,14 903.14 913,14 923.14 93- export/import: 943.14 95d:3.14; 963.14 97- debugging: 983.14 99float(3.14) 100float(3.14) 101- other: 1023.14 103