1--TEST-- 2Test printf() function : basic functionality - hexadecimal format 3--FILE-- 4<?php 5/* Prototype : int printf ( string $format [, mixed $args [, mixed $... ]] ) 6 * Description: Produces output according to format . 7 * Source code: ext/standard/formatted_print.c 8 */ 9 10echo "*** Testing printf() : basic functionality - using hexadecimal format ***\n"; 11 12// Initialise all required variables 13 14// Initialising different format strings 15$format = "format"; 16$format1 = "%x"; 17$format2 = "%x %x"; 18$format3 = "%x %x %x"; 19 20$format11 = "%X"; 21$format22 = "%X %X"; 22$format33 = "%X %X %X"; 23 24$arg1 = 11; 25$arg2 = 132; 26$arg3 = 177; 27 28echo "\n-- Calling printf() with no arguments --\n"; 29$result = printf($format); 30echo "\n"; 31var_dump($result); 32 33echo "\n-- Calling printf() with one arguments --\n"; 34$result = printf($format1, $arg1); 35echo "\n"; 36var_dump($result); 37$result = printf($format11, $arg1); 38echo "\n"; 39var_dump($result); 40 41echo "\n-- Calling printf() with two arguments --\n"; 42$result = printf($format2, $arg1, $arg2); 43echo "\n"; 44var_dump($result); 45$result = printf($format22, $arg1, $arg2); 46echo "\n"; 47var_dump($result); 48 49echo "\n-- Calling printf() with three arguments --\n"; 50$result = printf($format3, $arg1, $arg2, $arg3); 51echo "\n"; 52var_dump($result); 53$result = printf($format33, $arg1, $arg2, $arg3); 54echo "\n"; 55var_dump($result); 56 57?> 58===DONE=== 59--EXPECTF-- 60*** Testing printf() : basic functionality - using hexadecimal format *** 61 62-- Calling printf() with no arguments -- 63format 64int(6) 65 66-- Calling printf() with one arguments -- 67b 68int(1) 69B 70int(1) 71 72-- Calling printf() with two arguments -- 73b 84 74int(4) 75B 84 76int(4) 77 78-- Calling printf() with three arguments -- 79b 84 b1 80int(7) 81B 84 B1 82int(7) 83===DONE===