1
0
mirror of https://github.com/php/php-src.git synced 2026-04-26 01:18:19 +02:00
Files
archived-php-src/ext/standard/tests/file/readfile_error.phpt
T
Peter Kokot 6426420f61 Merge branch 'PHP-7.4'
* PHP-7.4:
  Replace dirname(__FILE__) by __DIR__ in tests
2019-03-15 23:36:47 +01:00

44 lines
1.2 KiB
PHP

--TEST--
Test readfile() function: error conditions
--FILE--
<?php
/* Prototype: int readfile ( string $filename [, bool $use_include_path [, resource $context]] );
Description: Outputs a file
*/
$context = stream_context_create();
echo "*** Test readfile(): error conditions ***\n";
echo "\n-- Testing readfile() with invalid arguments --\n";
// invalid arguments
var_dump( readfile(NULL) ); // NULL as $filename
var_dump( readfile('') ); // empty string as $filename
var_dump( readfile(false) ); // boolean false as $filename
echo "\n-- Testing readfile() with non-existent file --\n";
$non_existent_file = __DIR__."/non_existent_file.tmp";
var_dump( readfile($non_existent_file) );
echo "Done\n";
?>
--EXPECTF--
*** Test readfile(): error conditions ***
-- Testing readfile() with invalid arguments --
Warning: readfile(): Filename cannot be empty in %s on line %d
bool(false)
Warning: readfile(): Filename cannot be empty in %s on line %d
bool(false)
Warning: readfile(): Filename cannot be empty in %s on line %d
bool(false)
-- Testing readfile() with non-existent file --
Warning: readfile(%s/non_existent_file.tmp): failed to open stream: %s in %s on line %d
bool(false)
Done