2 /* Prototype : string sprintf(string $format [, mixed $arg1 [, mixed ...]])
3 * Description: Return a formatted string
4 * Source code: ext/standard/formatted_print.c
7 echo "*** Testing sprintf() : hexa formats with integer values ***\n";
9 // array of integer values
10 $integer_values = array(
14 -2147483648, // max negative integer value
16 2147483647, // max positive integer value
18 0x123B, // integer as hexadecimal
22 -0x80000000, // max negative integer as hexadecimal
23 0x7fffffff, // max postive integer as hexadecimal
24 0x7FFFFFFF, // max postive integer as hexadecimal
25 0123, // integer as octal
26 01912, // should be quivalent to octal 1
27 -020000000000, // max negative integer as octal
28 017777777777 // max positive integer as octal
31 // array of hexa formats
32 $hexa_formats = array(
35 "\t%x", "\n%x", "%4x",
36 "%30x", "%[0-9A-Fa-f]", "%*x"
40 foreach($integer_values as $integer_value) {
41 echo "\n-- Iteration $count --\n";
43 foreach($hexa_formats as $format) {
44 var_dump( sprintf($format, $integer_value) );