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 13$file_handle = fopen($file_path."/file_put_contents.tmp", "w"); 14 15echo "\n-- Testing for invalid negative maxlen values --\n"; 16file_put_contents($file_path."/file_put_contents1.tmp", "Garbage data in the file"); 17try { 18 file_get_contents($file_path."/file_put_contents1.tmp", FALSE, NULL, 0, -5); 19} catch (ValueError $exception) { 20 echo $exception->getMessage() . "\n"; 21} 22 23fclose($file_handle); 24 25echo "\n*** Done ***\n"; 26?> 27--CLEAN-- 28<?php 29$file_path = __DIR__; 30unlink($file_path."/file_put_contents.tmp"); 31unlink($file_path."/file_put_contents1.tmp"); 32 33?> 34--EXPECTF-- 35*** Testing error conditions *** 36 37-- Testing with Non-existing file -- 38 39Warning: file_get_contents(/no/such/file/or/dir): Failed to open stream: No such file or directory in %s on line %d 40 41-- Testing for invalid negative maxlen values -- 42file_get_contents(): Argument #5 ($length) must be greater than or equal to 0 43 44*** Done *** 45