1--TEST-- 2Test file_get_contents() function : error conditions 3--CREDITS-- 4Dave Kelsey <d_kelsey@uk.ibm.com> 5--FILE-- 6<?php 7 8echo "*** Testing error conditions ***\n"; 9 10$file_path = __DIR__; 11include($file_path."/file.inc"); 12 13echo "\n-- Testing with Non-existing file --\n"; 14print( file_get_contents("/no/such/file/or/dir") ); 15 16create_files($file_path, 1, "text", 0755, 100, "w", "file", 1, "byte"); 17$file_handle = fopen($file_path."/file_put_contents_error.tmp", "w"); 18 19echo "\n-- Testing for invalid negative maxlen values --\n"; 20try { 21 file_get_contents($file_path."/file1.tmp", FALSE, $file_handle, 0, -5); 22} catch (ValueError $exception) { 23 echo $exception->getMessage() . "\n"; 24} 25 26delete_files($file_path, 1); 27fclose($file_handle); 28unlink($file_path."/file_put_contents_error.tmp"); 29 30echo "\n*** Done ***\n"; 31?> 32--CLEAN-- 33<?php 34$file_path = __DIR__; 35if(file_exists($file_path."/file_put_contents_error.tmp")) { 36 unlink($file_path."/file_put_contents_error.tmp"); 37} 38if(file_exists($file_path."/file_put_contents1.tmp")) { 39 unlink($file_path."/file_put_contents1.tmp"); 40} 41?> 42--EXPECTF-- 43*** Testing error conditions *** 44 45-- Testing with Non-existing file -- 46 47Warning: file_get_contents(/no/such/file/or/dir): Failed to open stream: No such file or directory in %s on line %d 48 49-- Testing for invalid negative maxlen values -- 50file_get_contents(): Argument #5 ($length) must be greater than or equal to 0 51 52*** Done *** 53