1--TEST-- 2Test printf() function : basic functionality - exponential 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 exponential format ***\n"; 11 12// Initialise all required variables 13$format = "format"; 14$format1 = "%e"; 15$format2 = "%E %e"; 16$format3 = "%e %E %e"; 17$arg1 = 1000; 18$arg2 = 2e3; 19$arg3 = +3e3; 20 21echo "\n-- Calling printf() with no arguments --\n"; 22$result = printf($format); 23echo "\n"; 24var_dump($result); 25 26echo "\n-- Calling printf() with one argument --\n"; 27$result = printf($format1, $arg1); 28echo "\n"; 29var_dump($result); 30 31echo "\n-- Calling printf() with two arguments --\n"; 32$result = printf($format2, $arg1, $arg2); 33echo "\n"; 34var_dump($result); 35 36echo "\n-- Calling printf() with three arguments --\n"; 37$result = printf($format3, $arg1, $arg2, $arg3); 38echo "\n"; 39var_dump($result); 40?> 41===DONE=== 42--EXPECTF-- 43*** Testing printf() : basic functionality - using exponential format *** 44 45-- Calling printf() with no arguments -- 46format 47int(6) 48 49-- Calling printf() with one argument -- 501.000000e+3 51int(11) 52 53-- Calling printf() with two arguments -- 541.000000E+3 2.000000e+3 55int(23) 56 57-- Calling printf() with three arguments -- 581.000000e+3 2.000000E+3 3.000000e+3 59int(35) 60===DONE=== 61