1--TEST-- 2Test file-get_contents() and file_put_contents() functions : error conditions 3--FILE-- 4<?php 5 6echo "*** Testing error conditions ***\n"; 7 8$file_path = __DIR__; 9 10echo "\n-- Testing with Non-existing file --\n"; 11print( file_get_contents("/no/such/file/or/dir") ); 12 13echo "\n-- Testing for invalid negative maxlen values --\n"; 14file_put_contents($file_path."/file_put_contents_error1.tmp", "Garbage data in the file"); 15try { 16 file_get_contents($file_path."/file_put_contents_error1.tmp", FALSE, NULL, 0, -5); 17} catch (ValueError $exception) { 18 echo $exception->getMessage() . "\n"; 19} 20 21echo "\n*** Done ***\n"; 22?> 23--CLEAN-- 24<?php 25$file_path = __DIR__; 26unlink($file_path."/file_put_contents_error1.tmp"); 27 28?> 29--EXPECTF-- 30*** Testing error conditions *** 31 32-- Testing with Non-existing file -- 33 34Warning: file_get_contents(/no/such/file/or/dir): Failed to open stream: No such file or directory in %s on line %d 35 36-- Testing for invalid negative maxlen values -- 37file_get_contents(): Argument #5 ($length) must be greater than or equal to 0 38 39*** Done *** 40