1--TEST-- 2Test sprintf() function : usage variations - float formats with boolean values 3--FILE-- 4<?php 5/* Prototype : string sprintf(string $format [, mixed $arg1 [, mixed ...]]) 6 * Description: Return a formatted string 7 * Source code: ext/standard/formatted_print.c 8*/ 9 10echo "*** Testing sprintf() : float formats with boolean values ***\n"; 11 12// array of boolean type values 13$boolean_values = array ( 14 true, 15 false, 16 TRUE, 17 FALSE, 18); 19 20// various float formats 21$float_formats = array( 22 "%f", "%hf", "%lf", 23 "%Lf", " %f", "%f ", 24 "\t%f", "\n%f", "%4f", 25 "%30f", "%[0-9]", "%*f" 26); 27 28$count = 1; 29foreach($boolean_values as $boolean_value) { 30 echo "\n-- Iteration $count --\n"; 31 32 foreach($float_formats as $format) { 33 var_dump( sprintf($format, $boolean_value) ); 34 } 35 $count++; 36}; 37 38echo "Done"; 39?> 40--EXPECTF-- 41*** Testing sprintf() : float formats with boolean values *** 42 43-- Iteration 1 -- 44string(8) "1.000000" 45string(1) "f" 46string(8) "1.000000" 47string(1) "f" 48string(9) " 1.000000" 49string(9) "1.000000 " 50string(9) " 1.000000" 51string(9) " 521.000000" 53string(8) "1.000000" 54string(30) " 1.000000" 55string(4) "0-9]" 56string(1) "f" 57 58-- Iteration 2 -- 59string(8) "0.000000" 60string(1) "f" 61string(8) "0.000000" 62string(1) "f" 63string(9) " 0.000000" 64string(9) "0.000000 " 65string(9) " 0.000000" 66string(9) " 670.000000" 68string(8) "0.000000" 69string(30) " 0.000000" 70string(4) "0-9]" 71string(1) "f" 72 73-- Iteration 3 -- 74string(8) "1.000000" 75string(1) "f" 76string(8) "1.000000" 77string(1) "f" 78string(9) " 1.000000" 79string(9) "1.000000 " 80string(9) " 1.000000" 81string(9) " 821.000000" 83string(8) "1.000000" 84string(30) " 1.000000" 85string(4) "0-9]" 86string(1) "f" 87 88-- Iteration 4 -- 89string(8) "0.000000" 90string(1) "f" 91string(8) "0.000000" 92string(1) "f" 93string(9) " 0.000000" 94string(9) "0.000000 " 95string(9) " 0.000000" 96string(9) " 970.000000" 98string(8) "0.000000" 99string(30) " 0.000000" 100string(4) "0-9]" 101string(1) "f" 102Done