1--TEST-- 2Test readfile() function: error conditions 3--FILE-- 4<?php 5$context = stream_context_create(); 6 7echo "*** Test readfile(): error conditions ***\n"; 8 9echo "\n-- Testing readfile() with invalid arguments --\n"; 10// invalid arguments 11try { 12 var_dump( readfile('') ); // empty string as $filename 13} catch (\ValueError $e) { 14 echo $e->getMessage() . \PHP_EOL; 15} 16try { 17 var_dump( readfile(false) ); // boolean false as $filename 18} catch (\ValueError $e) { 19 echo $e->getMessage() . \PHP_EOL; 20} 21 22echo "\n-- Testing readfile() with non-existent file --\n"; 23$non_existent_file = __DIR__."/non_existent_file.tmp"; 24var_dump( readfile($non_existent_file) ); 25 26echo "Done\n"; 27?> 28--EXPECTF-- 29*** Test readfile(): error conditions *** 30 31-- Testing readfile() with invalid arguments -- 32Path must not be empty 33Path must not be empty 34 35-- Testing readfile() with non-existent file -- 36 37Warning: readfile(%s/non_existent_file.tmp): Failed to open stream: %s in %s on line %d 38bool(false) 39Done 40