1--TEST-- 2Test sprintf() function : usage variations - char formats with char values 3--FILE-- 4<?php 5echo "*** Testing sprintf() : char formats with char values ***\n"; 6 7// array of char values 8$char_values = array( 'a', "a", 67, -67, 99, ' ', '', 'A', "A" ); 9 10// array of char formats 11$char_formats = array( 12 "%c", "%lc", " %c", "%c ", 13 "\t%c", "\n%c", "%4c", "%30c", 14); 15 16$count = 1; 17foreach($char_values as $char_value) { 18 echo "\n-- Iteration $count --\n"; 19 20 foreach($char_formats as $format) { 21 var_dump( sprintf($format, $char_value) ); 22 } 23 $count++; 24}; 25 26echo "Done"; 27?> 28--EXPECTF-- 29*** Testing sprintf() : char formats with char values *** 30 31-- Iteration 1 -- 32string(1) "%0" 33string(1) "%0" 34string(2) " %0" 35string(2) "%0 " 36string(2) " %0" 37string(2) " 38%0" 39string(1) "%0" 40string(1) "%0" 41 42-- Iteration 2 -- 43string(1) "%0" 44string(1) "%0" 45string(2) " %0" 46string(2) "%0 " 47string(2) " %0" 48string(2) " 49%0" 50string(1) "%0" 51string(1) "%0" 52 53-- Iteration 3 -- 54string(1) "C" 55string(1) "C" 56string(2) " C" 57string(2) "C " 58string(2) " C" 59string(2) " 60C" 61string(1) "C" 62string(1) "C" 63 64-- Iteration 4 -- 65string(1) "�" 66string(1) "�" 67string(2) " �" 68string(2) "� " 69string(2) " �" 70string(2) " 71�" 72string(1) "�" 73string(1) "�" 74 75-- Iteration 5 -- 76string(1) "c" 77string(1) "c" 78string(2) " c" 79string(2) "c " 80string(2) " c" 81string(2) " 82c" 83string(1) "c" 84string(1) "c" 85 86-- Iteration 6 -- 87string(1) "%0" 88string(1) "%0" 89string(2) " %0" 90string(2) "%0 " 91string(2) " %0" 92string(2) " 93%0" 94string(1) "%0" 95string(1) "%0" 96 97-- Iteration 7 -- 98string(1) "%0" 99string(1) "%0" 100string(2) " %0" 101string(2) "%0 " 102string(2) " %0" 103string(2) " 104%0" 105string(1) "%0" 106string(1) "%0" 107 108-- Iteration 8 -- 109string(1) "%0" 110string(1) "%0" 111string(2) " %0" 112string(2) "%0 " 113string(2) " %0" 114string(2) " 115%0" 116string(1) "%0" 117string(1) "%0" 118 119-- Iteration 9 -- 120string(1) "%0" 121string(1) "%0" 122string(2) " %0" 123string(2) "%0 " 124string(2) " %0" 125string(2) " 126%0" 127string(1) "%0" 128string(1) "%0" 129Done 130