ZEND_PARSE_PARAMETERS_END();
if (ZEND_NUM_ARGS() == 5 && maxlen < 0) {
- php_error_docref(NULL, E_WARNING, "length must be greater than or equal to zero");
- RETURN_FALSE;
+ zend_value_error("Length must be greater than or equal to zero");
+ return;
}
context = php_stream_context_from_zval(zcontext, 0);
create_files($file_path, 1, "text", 0755, 100, "w", "file", 1, "byte");
$file_handle = fopen($file_path."/file_put_contents_error.tmp", "w");
-echo "\n-- Testing for invalid negative maxlen values --";
-var_dump( file_get_contents($file_path."/file1.tmp", FALSE, $file_handle, 0, -5) );
+echo "\n-- Testing for invalid negative maxlen values --\n";
+try {
+ file_get_contents($file_path."/file1.tmp", FALSE, $file_handle, 0, -5);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
delete_files($file_path, 1);
fclose($file_handle);
Warning: file_get_contents(/no/such/file/or/dir): failed to open stream: No such file or directory in %s on line %d
-- Testing for invalid negative maxlen values --
-Warning: file_get_contents(): length must be greater than or equal to zero in %s on line %d
-bool(false)
+Length must be greater than or equal to zero
*** Done ***
display_errors=false
--FILE--
<?php
- var_dump(file_get_contents("http://checkip.dyndns.com",null,null,0,-1));
+try {
+ file_get_contents("http://checkip.dyndns.com",null,null,0,-1);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
?>
--EXPECT--
-bool(false)
+Length must be greater than or equal to zero
$file_handle = fopen($file_path."/file_put_contents.tmp", "w");
-echo "\n-- Testing for invalid negative maxlen values --";
+echo "\n-- Testing for invalid negative maxlen values --\n";
file_put_contents($file_path."/file_put_contents1.tmp", "Garbage data in the file");
-var_dump( file_get_contents($file_path."/file_put_contents1.tmp", FALSE, NULL, 0, -5) );
+try {
+ file_get_contents($file_path."/file_put_contents1.tmp", FALSE, NULL, 0, -5);
+} catch (ValueError $exception) {
+ echo $exception->getMessage() . "\n";
+}
fclose($file_handle);
Warning: file_get_contents(/no/such/file/or/dir): failed to open stream: No such file or directory in %s on line %d
-- Testing for invalid negative maxlen values --
-Warning: file_get_contents(): length must be greater than or equal to zero in %s on line %d
-bool(false)
+Length must be greater than or equal to zero
*** Done ***