]> granicus.if.org Git - php/blob
fdaecd6fb3
[php] /
1 --TEST--
2 Test vfprintf() function : error conditions (more than expected arguments)
3 --CREDITS--
4 Felix De Vliegher <felix.devliegher@gmail.com>
5 --INI--
6 precision=14
7 --FILE--
8 <?php
9 /* Prototype  : int vfprintf(resource stream, string format, array args)
10  * Description: Output a formatted string into a stream
11  * Source code: ext/standard/formatted_print.c
12  * Alias to functions:
13  */
14
15 // Open handle
16 $file = 'vfprintf_error1.txt';
17 $fp = fopen( $file, "a+" );
18
19 echo "\n-- Testing vfprintf() function with more than expected no. of arguments --\n";
20 $format = 'string_val';
21 $args = array( 1, 2 );
22 $extra_arg = 10;
23 try {
24     var_dump( vfprintf( $fp, $format, $args, $extra_arg ) );
25 } catch (TypeError $e) {
26     echo $e->getMessage(), "\n";
27 }
28 try {
29     var_dump( vfprintf( $fp, "Foo %d", array(6), "bar" ) );
30 } catch (TypeError $e) {
31     echo $e->getMessage(), "\n";
32 }
33
34 // Close handle
35 fclose($fp);
36
37 ?>
38 --CLEAN--
39 <?php
40
41 $file = 'vfprintf_error1.txt';
42 unlink( $file );
43
44 ?>
45 --EXPECT--
46 -- Testing vfprintf() function with more than expected no. of arguments --
47 Wrong parameter count for vfprintf()
48 Wrong parameter count for vfprintf()