1--TEST-- 2Test vfprintf() function : usage variations - octal formats with octal values 3--SKIPIF-- 4<?php 5if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); 6?> 7--FILE-- 8<?php 9/* Prototype : int vfprintf ( resource $handle , string $format , array $args ) 10 * Description: Write a formatted string to a stream 11 * Source code: ext/standard/formatted_print.c 12*/ 13 14/* 15 * Test vfprintf() when different octal formats and octal values are passed to 16 * the '$format' and '$args' arguments of the function 17*/ 18 19echo "*** Testing vfprintf() : octal formats with octal values ***\n"; 20 21// defining array of octal formats 22$formats = array( 23 "%o", 24 "%+o %-o %O", 25 "%lo %Lo, %4o %-4o", 26 "%10.4o %-10.4o %04o %04.4o", 27 "%'#2o %'2o %'$2o %'_2o", 28 "%o %o %o %o", 29 "%% %%o %10 o%", 30 '%3$o %4$o %1$o %2$o' 31); 32 33// Arrays of octal values for the format defined in $format. 34// Each sub array contains octal values which correspond to each format string in $format 35$args_array = array( 36 array(00), 37 array(-01, 01, +022), 38 array(-020000000000, 020000000000, 017777777777, -017777777777), 39 array(0123456, 01234567, -01234567, 01234567), 40 array(0111, 02222, -0333333, -044444444), 41 array(0x123b, 0xfAb, 0123, 012), 42 array(01234, 0567, -01234, 02345), 43 array(03, 04, 01, 02) 44 45); 46 47/* creating dumping file */ 48$data_file = dirname(__FILE__) . '/vfprintf_variation11_64bit.txt'; 49if (!($fp = fopen($data_file, 'wt'))) 50 return; 51 52// looping to test vfprintf() with different octal formats from the above $formats array 53// and with octal values from the above $args_array array 54$counter = 1; 55foreach($formats as $format) { 56 fprintf($fp, "\n-- Iteration %d --\n",$counter); 57 vfprintf($fp, $format, $args_array[$counter-1]); 58 $counter++; 59} 60 61fclose($fp); 62print_r(file_get_contents($data_file)); 63echo "\n"; 64 65unlink($data_file); 66 67?> 68===DONE=== 69--EXPECT-- 70*** Testing vfprintf() : octal formats with octal values *** 71 72-- Iteration 1 -- 730 74-- Iteration 2 -- 751777777777777777777777 1 76-- Iteration 3 -- 771777777777760000000000 o, 17777777777 1777777777760000000001 78-- Iteration 4 -- 79 1777777777777776543211 0000 80-- Iteration 5 -- 81111 2222 1777777777777777444445 1777777777777733333334 82-- Iteration 6 -- 8311073 7653 123 12 84-- Iteration 7 -- 85% %o o 86-- Iteration 8 -- 871 2 3 4 88===DONE=== 89