1--TEST-- 2Test file_get_contents() function : variation - various absolute and relative paths 3--CREDITS-- 4Dave Kelsey <d_kelsey@uk.ibm.com> 5--SKIPIF-- 6<?php 7if(substr(PHP_OS, 0, 3) != "WIN") 8 die("skip Only run on Windows"); 9?> 10--FILE-- 11<?php 12echo "*** Testing file_get_contents() : variation ***\n"; 13$mainDir = "fileGetContentsVar7私はガラスを食べられます.dir"; 14$subDir = "fileGetContentsVar7Sub私はガラスを食べられます"; 15$absMainDir = __DIR__."\\".$mainDir; 16mkdir($absMainDir); 17$absSubDir = $absMainDir."\\".$subDir; 18mkdir($absSubDir); 19 20$old_dir_path = getcwd(); 21chdir(__DIR__); 22$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3); 23 24$allDirs = array( 25 // absolute paths 26 "$absSubDir\\", 27 "$absSubDir\\..\\".$subDir, 28 "$absSubDir\\\\..\\.\\".$subDir, 29 "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir, 30 "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir, 31 "$absSubDir\\BADDIR", 32 33 // relative paths 34 $mainDir."\\".$subDir, 35 $mainDir."\\\\".$subDir, 36 $mainDir."\\\\\\".$subDir, 37 ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir, 38 "BADDIR", 39 40 // unixifed path 41 $unixifiedDir, 42); 43 44$filename = 'FileGetContentsVar7.tmp'; 45$absFile = $absSubDir.'/'.$filename; 46$h = fopen($absFile,"w"); 47fwrite($h, "contents read"); 48fclose($h); 49 50for($i = 0; $i<count($allDirs); $i++) { 51 $j = $i+1; 52 $dir = $allDirs[$i]; 53 echo "\n-- Iteration $j --\n"; 54 var_dump(file_get_contents($dir."\\".$filename)); 55} 56 57chdir($old_dir_path); 58 59echo "\n*** Done ***\n"; 60?> 61--CLEAN-- 62<?php 63$mainDir = "fileGetContentsVar7私はガラスを食べられます.dir"; 64$subDir = "fileGetContentsVar7Sub私はガラスを食べられます"; 65$absMainDir = __DIR__."/".$mainDir; 66$absSubDir = $absMainDir."/".$subDir; 67$filename = 'FileGetContentsVar7.tmp'; 68$absFile = $absSubDir.'/'.$filename; 69unlink($absFile); 70rmdir($absSubDir); 71rmdir($absMainDir); 72?> 73--EXPECTF-- 74*** Testing file_get_contents() : variation *** 75 76-- Iteration 1 -- 77string(%d) "contents read" 78 79-- Iteration 2 -- 80string(%d) "contents read" 81 82-- Iteration 3 -- 83string(%d) "contents read" 84 85-- Iteration 4 -- 86string(%d) "contents read" 87 88-- Iteration 5 -- 89 90Warning: file_get_contents(%sfileGetContentsVar7私はガラスを食べられます.dir\fileGetContentsVar7Sub私はガラスを食べられます\..\\\fileGetContentsVar7Sub私はガラスを食べられます\\..\\..\fileGetContentsVar7Sub私はガラスを食べられます\FileGetContentsVar7.tmp): Failed to open stream: No such file or directory in %s on line %d 91bool(false) 92 93-- Iteration 6 -- 94 95Warning: file_get_contents(%sfileGetContentsVar7私はガラスを食べられます.dir\fileGetContentsVar7Sub私はガラスを食べられます\BADDIR\FileGetContentsVar7.tmp): Failed to open stream: No such file or directory in %s on line %d 96bool(false) 97 98-- Iteration 7 -- 99string(%d) "contents read" 100 101-- Iteration 8 -- 102string(%d) "contents read" 103 104-- Iteration 9 -- 105string(%d) "contents read" 106 107-- Iteration 10 -- 108string(%d) "contents read" 109 110-- Iteration 11 -- 111 112Warning: file_get_contents(BADDIR\FileGetContentsVar7.tmp): Failed to open stream: No such file or directory in %s on line %d 113bool(false) 114 115-- Iteration 12 -- 116string(%d) "contents read" 117 118*** Done *** 119