Return to sprintf_basic8.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / strings |
1.1 misho 1: --TEST-- 2: Test sprintf() function : basic functionality - octal format 3: --SKIPIF-- 4: <?php 5: if (PHP_INT_SIZE != 4) { 6: die("skip this test is for 32bit platform only"); 7: } 8: ?> 9: --FILE-- 10: <?php 11: /* Prototype : string sprintf(string $format [, mixed $arg1 [, mixed ...]]) 12: * Description: Return a formatted string 13: * Source code: ext/standard/formatted_print.c 14: */ 15: 16: echo "*** Testing sprintf() : basic functionality - using octal format ***\n"; 17: 18: // Initialise all required variables 19: $format = "format"; 20: $format1 = "%o"; 21: $format2 = "%o %o"; 22: $format3 = "%o %o %o"; 23: $arg1 = 021; 24: $arg2 = -0347; 25: $arg3 = 05678; 26: 27: // Calling sprintf() with default arguments 28: var_dump( sprintf($format) ); 29: 30: // Calling sprintf() with two arguments 31: var_dump( sprintf($format1, $arg1) ); 32: 33: // Calling sprintf() with three arguments 34: var_dump( sprintf($format2, $arg1, $arg2) ); 35: 36: // Calling sprintf() with four arguments 37: var_dump( sprintf($format3, $arg1, $arg2, $arg3) ); 38: 39: echo "Done"; 40: ?> 41: --EXPECTF-- 42: *** Testing sprintf() : basic functionality - using octal format *** 43: string(6) "format" 44: string(2) "21" 45: string(14) "21 37777777431" 46: string(18) "21 37777777431 567" 47: Done