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