1--TEST-- 2Test sprintf() function : basic functionality - hexadecimal format 3--FILE-- 4<?php 5echo "*** Testing sprintf() : basic functionality - using hexadecimal format ***\n"; 6 7// Initialise all required variables 8 9// Initialising different format strings 10$format = "format"; 11$format1 = "%x"; 12$format2 = "%x %x"; 13$format3 = "%x %x %x"; 14 15$format11 = "%X"; 16$format22 = "%X %X"; 17$format33 = "%X %X %X"; 18 19$arg1 = 11; 20$arg2 = 132; 21$arg3 = 177; 22 23// Calling sprintf() with default arguments 24var_dump( sprintf($format) ); 25 26// Calling sprintf() with two arguments 27var_dump( sprintf($format1, $arg1) ); 28var_dump( sprintf($format11, $arg1) ); 29 30// Calling sprintf() with three arguments 31var_dump( sprintf($format2, $arg1, $arg2) ); 32var_dump( sprintf($format22, $arg1, $arg2) ); 33 34// Calling sprintf() with four arguments 35var_dump( sprintf($format3, $arg1, $arg2, $arg3) ); 36var_dump( sprintf($format33, $arg1, $arg2, $arg3) ); 37 38echo "Done"; 39?> 40--EXPECT-- 41*** Testing sprintf() : basic functionality - using hexadecimal format *** 42string(6) "format" 43string(1) "b" 44string(1) "B" 45string(4) "b 84" 46string(4) "B 84" 47string(7) "b 84 b1" 48string(7) "B 84 B1" 49Done 50