2008-11-26 10:10:19 +00:00
|
|
|
--TEST--
|
|
|
|
Test file_get_contents() function : variation - obscure filenames
|
|
|
|
--CREDITS--
|
|
|
|
Dave Kelsey <d_kelsey@uk.ibm.com>
|
|
|
|
--SKIPIF--
|
|
|
|
<?php
|
|
|
|
if(substr(PHP_OS, 0, 3) != "WIN")
|
|
|
|
die("skip Only run on Windows");
|
|
|
|
?>
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
/* Prototype : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
|
|
|
|
* Description: Read the entire file into a string
|
|
|
|
* Source code: ext/standard/file.c
|
|
|
|
* Alias to functions:
|
|
|
|
*/
|
|
|
|
|
|
|
|
echo "*** Testing file_get_contents() : variation ***\n";
|
2009-01-12 15:59:04 +00:00
|
|
|
|
2008-11-26 10:10:19 +00:00
|
|
|
/* An array of filenames */
|
|
|
|
$names_arr = array(
|
2009-01-12 15:59:04 +00:00
|
|
|
/* Invalid args */
|
|
|
|
"-1" => -1,
|
|
|
|
"TRUE" => TRUE,
|
|
|
|
"FALSE" => FALSE,
|
|
|
|
"NULL" => NULL,
|
|
|
|
"\"\"" => "",
|
|
|
|
"\" \"" => " ",
|
|
|
|
"\\0" => "\0",
|
|
|
|
"array()" => array(),
|
|
|
|
|
|
|
|
/* prefix with path separator of a non existing directory*/
|
|
|
|
"/no/such/file/dir" => "/no/such/file/dir",
|
|
|
|
"php/php"=> "php/php"
|
2008-11-26 10:10:19 +00:00
|
|
|
|
|
|
|
);
|
|
|
|
|
2009-01-12 15:59:04 +00:00
|
|
|
foreach($names_arr as $key =>$value) {
|
|
|
|
echo "\n-- Filename: $key --\n";
|
|
|
|
var_dump(file_get_contents($value));
|
2008-11-26 10:10:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
2009-01-12 15:59:04 +00:00
|
|
|
===Done===
|
2008-11-26 10:10:19 +00:00
|
|
|
--EXPECTF--
|
|
|
|
*** Testing file_get_contents() : variation ***
|
2009-01-12 15:59:04 +00:00
|
|
|
|
|
|
|
-- Filename: -1 --
|
2008-11-26 10:10:19 +00:00
|
|
|
|
|
|
|
Warning: file_get_contents(-1): failed to open stream: No such file or directory in %s on line %d
|
|
|
|
bool(false)
|
2009-01-12 15:59:04 +00:00
|
|
|
|
|
|
|
-- Filename: TRUE --
|
2008-11-26 10:10:19 +00:00
|
|
|
|
|
|
|
Warning: file_get_contents(1): failed to open stream: No such file or directory in %s on line %d
|
|
|
|
bool(false)
|
2009-01-12 15:59:04 +00:00
|
|
|
|
|
|
|
-- Filename: FALSE --
|
|
|
|
|
|
|
|
Warning: file_get_contents(): Filename cannot be empty in %s on line %d
|
2008-11-26 10:10:19 +00:00
|
|
|
bool(false)
|
2009-01-12 15:59:04 +00:00
|
|
|
|
|
|
|
-- Filename: NULL --
|
|
|
|
|
|
|
|
Warning: file_get_contents(): Filename cannot be empty in %s on line %d
|
2008-11-26 10:10:19 +00:00
|
|
|
bool(false)
|
2009-01-12 15:59:04 +00:00
|
|
|
|
|
|
|
-- Filename: "" --
|
|
|
|
|
|
|
|
Warning: file_get_contents(): Filename cannot be empty in %s on line %d
|
2008-11-26 10:10:19 +00:00
|
|
|
bool(false)
|
2009-01-12 15:59:04 +00:00
|
|
|
|
|
|
|
-- Filename: " " --
|
2008-11-26 10:10:19 +00:00
|
|
|
|
|
|
|
Warning: file_get_contents( ): failed to open stream: Permission denied in %s on line %d
|
|
|
|
bool(false)
|
2009-01-12 15:59:04 +00:00
|
|
|
|
|
|
|
-- Filename: \0 --
|
|
|
|
|
|
|
|
Warning: file_get_contents(): Filename cannot be empty in %s on line %d
|
2008-11-26 10:10:19 +00:00
|
|
|
bool(false)
|
2009-01-12 15:59:04 +00:00
|
|
|
|
|
|
|
-- Filename: array() --
|
2008-11-26 10:10:19 +00:00
|
|
|
|
|
|
|
Warning: file_get_contents() expects parameter 1 to be string, array given in %s on line %d
|
|
|
|
NULL
|
2009-01-12 15:59:04 +00:00
|
|
|
|
|
|
|
-- Filename: /no/such/file/dir --
|
2008-11-26 10:10:19 +00:00
|
|
|
|
|
|
|
Warning: file_get_contents(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
|
|
|
|
bool(false)
|
2009-01-12 15:59:04 +00:00
|
|
|
|
|
|
|
-- Filename: php/php --
|
2008-11-26 10:10:19 +00:00
|
|
|
|
|
|
|
Warning: file_get_contents(php/php): failed to open stream: No such file or directory in %s on line %d
|
|
|
|
bool(false)
|
2009-01-12 15:59:04 +00:00
|
|
|
===Done===
|