1--TEST-- 2file() with various paths 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) != 'WIN') { 6 die('skip windows only test'); 7} 8?> 9--FILE-- 10<?php 11 12$script_directory = __DIR__; 13chdir($script_directory); 14$test_dirname = basename(__FILE__, ".php") . "私はガラスを食べられますtestdir"; 15mkdir($test_dirname); 16 17$filepath = __DIR__ . '/file_variation_5_mb.tmp'; 18$filename = basename($filepath); 19$fd = fopen($filepath, "w+"); 20fwrite($fd, "Line 1\nLine 2\nLine 3"); 21fclose($fd); 22 23echo "file() on a path containing .. and .\n"; 24var_dump(file("./$test_dirname/../$filename")); 25 26echo "\nfile() on a path containing .. with invalid directories\n"; 27var_dump(file("./$test_dirname/bad_dir/../../$filename")); 28 29echo "\nfile() on a relative path from a different working directory\n"; 30chdir($test_dirname); 31var_dump(file("../$filename")); 32chdir($script_directory); 33 34?> 35--CLEAN-- 36<?php 37$test_dirname = __DIR__ . '/' . basename(__FILE__, ".clean.php") . "私はガラスを食べられますtestdir"; 38$filepath = __DIR__ . '/file_variation_5_mb.tmp'; 39@unlink($filepath); 40rmdir($test_dirname); 41?> 42--EXPECT-- 43file() on a path containing .. and . 44array(3) { 45 [0]=> 46 string(7) "Line 1 47" 48 [1]=> 49 string(7) "Line 2 50" 51 [2]=> 52 string(6) "Line 3" 53} 54 55file() on a path containing .. with invalid directories 56array(3) { 57 [0]=> 58 string(7) "Line 1 59" 60 [1]=> 61 string(7) "Line 2 62" 63 [2]=> 64 string(6) "Line 3" 65} 66 67file() on a relative path from a different working directory 68array(3) { 69 [0]=> 70 string(7) "Line 1 71" 72 [1]=> 73 string(7) "Line 2 74" 75 [2]=> 76 string(6) "Line 3" 77} 78