1--TEST-- 2sprintf With signed integer 3--FILE-- 4<?php 5 6/* example#5: various examples */ 7$n = 43951789; 8$u = -43951789; 9$c = 65; // ASCII 65 is 'A' 10 11// notice the double %%, this prints a literal '%' character 12var_dump(sprintf("%%b = '%b'", $n)); // binary representation 13var_dump(sprintf("%%c = '%c'", $c)); // print the ascii character, same as chr() function 14var_dump(sprintf("%%d = '%d'", $n)); // standard integer representation 15var_dump(sprintf("%%e = '%e'", $n)); // scientific notation 16var_dump(sprintf("%%f = '%f'", $n)); // floating point representation 17var_dump(sprintf("%%o = '%o'", $n)); // octal representation 18var_dump(sprintf("%%s = '%s'", $n)); // string representation 19var_dump(sprintf("%%x = '%x'", $n)); // hexadecimal representation (lower-case) 20var_dump(sprintf("%%X = '%X'", $n)); // hexadecimal representation (upper-case) 21 22var_dump(sprintf("%%+d = '%+d'", $n)); // sign specifier on a positive integer 23var_dump(sprintf("%%+d = '%+d'", $u)); // sign specifier on a negative integer 24 25?> 26--EXPECT-- 27string(33) "%b = '10100111101010011010101101'" 28string(8) "%c = 'A'" 29string(15) "%d = '43951789'" 30string(18) "%e = '4.395179e+7'" 31string(22) "%f = '43951789.000000'" 32string(16) "%o = '247523255'" 33string(15) "%s = '43951789'" 34string(14) "%x = '29ea6ad'" 35string(14) "%X = '29EA6AD'" 36string(17) "%+d = '+43951789'" 37string(17) "%+d = '-43951789'" 38