1--TEST-- 2Test sprintf() function : usage variations - hexa formats with resource values 3--FILE-- 4<?php 5/* Prototype : string sprintf(string $format [, mixed $arg1 [, mixed ...]]) 6 * Description: Return a formatted string 7 * Source code: ext/standard/formatted_print.c 8*/ 9 10echo "*** Testing sprintf() : hexa formats with resource values ***\n"; 11 12// resource type variable 13$fp = fopen (__FILE__, "r"); 14$dfp = opendir ( __DIR__ ); 15 16// array of resource types 17$resource_values = array ( 18 $fp, 19 $dfp 20); 21 22// array of hexa formats 23$hexa_formats = array( 24 "%x", "%xx", "%lx", 25 "%Lx", " %x", "%x ", 26 "\t%x", "\n%x", "%4x", 27 "%30x", "%[0-9A-Fa-f]", "%*x" 28); 29 30$count = 1; 31foreach($resource_values as $resource_value) { 32 echo "\n-- Iteration $count --\n"; 33 34 foreach($hexa_formats as $format) { 35 var_dump( sprintf($format, $resource_value) ); 36 } 37 $count++; 38}; 39 40// closing the resources 41fclose($fp); 42closedir($dfp); 43 44?> 45===DONE=== 46--EXPECTF-- 47*** Testing sprintf() : hexa formats with resource values *** 48 49-- Iteration 1 -- 50string(%d) "%a" 51string(%d) "%ax" 52string(%d) "%a" 53string(1) "x" 54string(%d) " %a" 55string(%d) "%a " 56string(%d) " %a" 57string(%d) " 58%a" 59string(4) "%a" 60string(30) "%a" 61string(10) "0-9A-Fa-f]" 62string(1) "x" 63 64-- Iteration 2 -- 65string(%d) "%a" 66string(%d) "%ax" 67string(%d) "%a" 68string(1) "x" 69string(%d) " %a" 70string(%d) "%a " 71string(%d) " %a" 72string(%d) " 73%a" 74string(4) "%a" 75string(30) "%a" 76string(10) "0-9A-Fa-f]" 77string(1) "x" 78===DONE=== 79