1--TEST-- 2Test readfile() function : variation - various invalid paths 3--CREDITS-- 4Dave Kelsey <d_kelsey@uk.ibm.com> 5--SKIPIF-- 6<?php 7if(substr(PHP_OS, 0, 3) != "WIN") 8 die("skip run only on Windows"); 9?> 10--CONFLICTS-- 11obscure_filename 12--FILE-- 13<?php 14echo "*** Testing readfile() : variation ***\n"; 15 16/* An array of files */ 17$names_arr = array( 18 /* Invalid args */ 19 "-1" => -1, 20 "TRUE" => TRUE, 21 "FALSE" => FALSE, 22 "NULL" => NULL, 23 "\"\"" => "", 24 "\" \"" => " ", 25 "\\0" => "\0", 26 "array()" => array(), 27 28 /* prefix with path separator of a non existing directory*/ 29 "/no/such/file/dir" => "/no/such/file/dir", 30 "php/php"=> "php/php" 31 32); 33 34foreach($names_arr as $key => $value) { 35 echo "\n-- Filename: $key --\n"; 36 try { 37 readfile($value); 38 } catch (\TypeError|\ValueError $e) { 39 echo get_class($e) . ': ' . $e->getMessage(), "\n"; 40 } 41} 42?> 43--EXPECTF-- 44*** Testing readfile() : variation *** 45 46-- Filename: -1 -- 47 48Warning: readfile(-1): Failed to open stream: No such file or directory in %s on line %d 49 50-- Filename: TRUE -- 51 52Warning: readfile(1): Failed to open stream: No such file or directory in %s on line %d 53 54-- Filename: FALSE -- 55ValueError: Path cannot be empty 56 57-- Filename: NULL -- 58ValueError: Path cannot be empty 59 60-- Filename: "" -- 61ValueError: Path cannot be empty 62 63-- Filename: " " -- 64 65Warning: readfile( ): Failed to open stream: Permission denied in %s on line %d 66 67-- Filename: \0 -- 68ValueError: readfile(): Argument #1 ($filename) must not contain any null bytes 69 70-- Filename: array() -- 71TypeError: readfile(): Argument #1 ($filename) must be of type string, array given 72 73-- Filename: /no/such/file/dir -- 74 75Warning: readfile(/no/such/file/dir): Failed to open stream: No such file or directory in %s on line %d 76 77-- Filename: php/php -- 78 79Warning: readfile(php/php): Failed to open stream: No such file or directory in %s on line %d 80