1--TEST-- 2Test parse_ini_file() 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 parse_ini_file() : variation ***\n"; 13$mainDir = "parseIniFileVar私はガラスを食べられます.dir"; 14$subDir = "parseIniFileVar私はガラスを食べられますSub"; 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 = 'parseIniFileVar私はガラスを食べられます.ini'; 45$content="a=test"; 46$absFile = $absSubDir.'/'.$filename; 47$h = fopen($absFile,"w"); 48fwrite($h, $content); 49fclose($h); 50 51for($i = 0; $i<count($allDirs); $i++) { 52 $j = $i+1; 53 $dir = $allDirs[$i]; 54 echo "\n-- Iteration $j --\n"; 55 var_dump(parse_ini_file($dir."\\".$filename)); 56} 57 58unlink($absFile); 59chdir($old_dir_path); 60rmdir($absSubDir); 61rmdir($absMainDir); 62 63echo "\n*** Done ***\n"; 64?> 65--EXPECTF-- 66*** Testing parse_ini_file() : variation *** 67 68-- Iteration 1 -- 69array(1) { 70 ["a"]=> 71 string(4) "test" 72} 73 74-- Iteration 2 -- 75array(1) { 76 ["a"]=> 77 string(4) "test" 78} 79 80-- Iteration 3 -- 81array(1) { 82 ["a"]=> 83 string(4) "test" 84} 85 86-- Iteration 4 -- 87array(1) { 88 ["a"]=> 89 string(4) "test" 90} 91 92-- Iteration 5 -- 93 94Warning: parse_ini_file(%sparseIniFileVar私はガラスを食べられます.dir\parseIniFileVar私はガラスを食べられますSub\..\\\parseIniFileVar私はガラスを食べられますSub\\..\\..\parseIniFileVar私はガラスを食べられますSub\parseIniFileVar私はガラスを食べられます.ini): Failed to open stream: No such file or directory in %s on line %d 95bool(false) 96 97-- Iteration 6 -- 98 99Warning: parse_ini_file(%sparseIniFileVar私はガラスを食べられます.dir\parseIniFileVar私はガラスを食べられますSub\BADDIR\parseIniFileVar私はガラスを食べられます.ini): Failed to open stream: No such file or directory in %s on line %d 100bool(false) 101 102-- Iteration 7 -- 103array(1) { 104 ["a"]=> 105 string(4) "test" 106} 107 108-- Iteration 8 -- 109array(1) { 110 ["a"]=> 111 string(4) "test" 112} 113 114-- Iteration 9 -- 115array(1) { 116 ["a"]=> 117 string(4) "test" 118} 119 120-- Iteration 10 -- 121array(1) { 122 ["a"]=> 123 string(4) "test" 124} 125 126-- Iteration 11 -- 127 128Warning: parse_ini_file(BADDIR\parseIniFileVar私はガラスを食べられます.ini): Failed to open stream: No such file or directory in %s on line %d 129bool(false) 130 131-- Iteration 12 -- 132array(1) { 133 ["a"]=> 134 string(4) "test" 135} 136 137*** Done *** 138