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 7/* Prototype : array parse_ini_file(string filename [, bool process_sections]) 8 * Description: Parse configuration file 9 * Source code: ext/standard/basic_functions.c 10 * Alias to functions: 11 */ 12 13echo "*** Testing parse_ini_file() : variation ***\n"; 14$mainDir = "parseIniFileVar6.dir"; 15$subDir = "parseIniFileVar6Sub"; 16$absMainDir = dirname(__FILE__)."/".$mainDir; 17mkdir($absMainDir); 18$absSubDir = $absMainDir."/".$subDir; 19mkdir($absSubDir); 20 21$old_dir_path = getcwd(); 22chdir(dirname(__FILE__)); 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); 41 42$filename = 'ParseIniFileVar6.ini'; 43$content="a=test"; 44$absFile = $absSubDir.'/'.$filename; 45$h = fopen($absFile,"w"); 46fwrite($h, $content); 47fclose($h); 48 49for($i = 0; $i<count($allDirs); $i++) { 50 $j = $i+1; 51 $dir = $allDirs[$i]; 52 echo "\n-- Iteration $j --\n"; 53 var_dump(parse_ini_file($dir."/".$filename)); 54} 55 56unlink($absFile); 57chdir($old_dir_path); 58rmdir($absSubDir); 59rmdir($absMainDir); 60 61echo "\n*** Done ***\n"; 62?> 63--EXPECTF-- 64*** Testing parse_ini_file() : variation *** 65 66-- Iteration 1 -- 67array(1) { 68 ["a"]=> 69 string(4) "test" 70} 71 72-- Iteration 2 -- 73array(1) { 74 ["a"]=> 75 string(4) "test" 76} 77 78-- Iteration 3 -- 79array(1) { 80 ["a"]=> 81 string(4) "test" 82} 83 84-- Iteration 4 -- 85array(1) { 86 ["a"]=> 87 string(4) "test" 88} 89 90-- Iteration 5 -- 91 92Warning: parse_ini_file(%sparseIniFileVar6.dir/parseIniFileVar6Sub/..///parseIniFileVar6Sub//..//../parseIniFileVar6Sub/ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d 93bool(false) 94 95-- Iteration 6 -- 96 97Warning: parse_ini_file(%sparseIniFileVar6.dir/parseIniFileVar6Sub/BADDIR/ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d 98bool(false) 99 100-- Iteration 7 -- 101array(1) { 102 ["a"]=> 103 string(4) "test" 104} 105 106-- Iteration 8 -- 107array(1) { 108 ["a"]=> 109 string(4) "test" 110} 111 112-- Iteration 9 -- 113array(1) { 114 ["a"]=> 115 string(4) "test" 116} 117 118-- Iteration 10 -- 119array(1) { 120 ["a"]=> 121 string(4) "test" 122} 123 124-- Iteration 11 -- 125 126Warning: parse_ini_file(BADDIR/ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d 127bool(false) 128 129*** Done ***