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// Open handle 10$file = 'vfprintf_error3.txt'; 11$fp = fopen( $file, "a+" ); 12 13echo "\n-- Testing vfprintf() function with wrong variable types as argument --\n"; 14try { 15 vfprintf($fp, array( 'foo %d', 'bar %s' ), 3.55552); 16} catch (TypeError $exception) { 17 echo $exception->getMessage() . "\n"; 18} 19 20try { 21 vfprintf($fp, "Foo: %s", "not available"); 22} catch (TypeError $e) { 23 echo $e->getMessage(), "\n"; 24} 25 26try { 27 vfprintf($fp, "Foo %y fake", ["not available"]); 28} catch (ValueError $e) { 29 echo $e->getMessage(), "\n"; 30} 31 32rewind( $fp ); 33var_dump( stream_get_contents( $fp ) ); 34ftruncate( $fp, 0 ); 35rewind( $fp ); 36 37// Close handle 38fclose( $fp ); 39 40?> 41--CLEAN-- 42<?php 43 44$file = 'vfprintf_error3.txt'; 45unlink( $file ); 46 47?> 48--EXPECT-- 49-- Testing vfprintf() function with wrong variable types as argument -- 50vfprintf(): Argument #2 ($format) must be of type string, array given 51vfprintf(): Argument #3 ($values) must be of type array, string given 52Unknown format specifier "y" 53string(0) "" 54