1--TEST--
2Test vfprintf() function : error conditions (wrong argument types)
3--CREDITS--
4Felix De Vliegher <felix.devliegher@gmail.com>
5--INI--
6precision=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_test.txt';
17$fp = fopen( $file, "a+" );
18
19echo "\n-- Testing vfprintf() function with wrong variable types as argument --\n";
20var_dump( vfprintf( $fp, array( 'foo %d', 'bar %s' ), 3.55552 ) );
21
22rewind( $fp );
23var_dump( stream_get_contents( $fp ) );
24ftruncate( $fp, 0 );
25rewind( $fp );
26
27var_dump( vfprintf( $fp, "Foo %y fake", "not available" ) );
28
29rewind( $fp );
30var_dump( stream_get_contents( $fp ) );
31ftruncate( $fp, 0 );
32rewind( $fp );
33
34// Close handle
35fclose( $fp );
36
37?>
38===DONE===
39--CLEAN--
40<?php
41
42$file = 'vfprintf_test.txt';
43unlink( $file );
44
45?>
46--EXPECTF--
47-- Testing vfprintf() function with wrong variable types as argument --
48
49Notice: Array to string conversion in %s on line %d
50int(5)
51string(5) "Array"
52int(9)
53string(9) "Foo  fake"
54===DONE===
55