1--TEST-- 2parse_ini_file() multiple calls 3--SKIPIF-- 4<?php if( substr(PHP_OS, 0, 3) == 'WIN' ) die("skip Windows has different error message");?> 5--FILE-- 6<?php 7 8$filename = dirname(__FILE__)."/parse_ini_file.dat"; 9@unlink($filename); /* Make sure the file really does not exist! */ 10 11var_dump(parse_ini_file()); 12var_dump(parse_ini_file(1,1,1,1)); 13var_dump(parse_ini_file($filename)); 14var_dump(parse_ini_file($filename, true)); 15 16$ini = " 17test = 18"; 19file_put_contents($filename, $ini); 20var_dump(parse_ini_file($filename)); 21$ini = " 22test== 23"; 24file_put_contents($filename, $ini); 25var_dump(parse_ini_file($filename)); 26 27$ini = " 28test=test= 29"; 30file_put_contents($filename, $ini); 31var_dump(parse_ini_file($filename)); 32 33$ini = " 34test= \"new 35line\" 36"; 37file_put_contents($filename, $ini); 38var_dump(parse_ini_file($filename)); 39 40define("TEST_CONST", "test const value"); 41$ini = " 42test=TEST_CONST 43"; 44file_put_contents($filename, $ini); 45var_dump(parse_ini_file($filename)); 46 47$ini = " 48[section] 49test=hello 50"; 51file_put_contents($filename, $ini); 52var_dump(parse_ini_file($filename, true)); 53 54$ini = " 55[section] 56test=hello 57"; 58file_put_contents($filename, $ini); 59var_dump(parse_ini_file($filename, false)); 60 61$ini = " 62section.test=hello 63"; 64file_put_contents($filename, $ini); 65var_dump(parse_ini_file($filename, true)); 66 67$ini = " 68[section] 69section.test=hello 70"; 71file_put_contents($filename, $ini); 72var_dump(parse_ini_file($filename, true)); 73 74$ini = " 75[section] 761=2 77"; 78file_put_contents($filename, $ini); 79var_dump(parse_ini_file($filename, true)); 80 81$ini = " 821=2 83"; 84file_put_contents($filename, $ini); 85var_dump(parse_ini_file($filename, true)); 86$ini = " 87test=test2 88test=test3 89test=test4 90"; 91file_put_contents($filename, $ini); 92var_dump(parse_ini_file($filename, true)); 93 94/* From bug #44574 */ 95$ini = "[section1]\nname = value"; 96file_put_contents($filename, $ini); 97var_dump(parse_ini_file($filename, true)); 98 99/* #44842, labels starting with underscore */ 100$ini = <<<'INI' 101foo=bar1 102_foo=bar2 103foo_=bar3 104INI; 105file_put_contents($filename, $ini); 106var_dump(parse_ini_file($filename, true)); 107 108/* #44575, comments starting with '#' */ 109$ini = <<<'INI' 110foo=bar1 111; comment 112_foo=bar2 113; comment 114foo_=bar3 115INI; 116file_put_contents($filename, $ini); 117var_dump(parse_ini_file($filename, true)); 118 119 120@unlink($filename); 121echo "Done\n"; 122?> 123--EXPECTF-- 124Warning: parse_ini_file() expects at least 1 parameter, 0 given in %sparse_ini_file.php on line 6 125bool(false) 126 127Warning: parse_ini_file() expects at most 3 parameters, 4 given in %sparse_ini_file.php on line 7 128bool(false) 129 130Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %sparse_ini_file.php on line 8 131bool(false) 132 133Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %sparse_ini_file.php on line 9 134bool(false) 135array(1) { 136 ["test"]=> 137 string(0) "" 138} 139 140Warning: syntax error, unexpected '='%sparse_ini_file.dat on line 2 141 in %sparse_ini_file.php on line 20 142bool(false) 143 144Warning: syntax error, unexpected '='%sparse_ini_file.dat on line 2 145 in %sparse_ini_file.php on line 26 146bool(false) 147array(1) { 148 ["test"]=> 149 string(8) "new 150line" 151} 152array(1) { 153 ["test"]=> 154 string(16) "test const value" 155} 156array(1) { 157 ["section"]=> 158 array(1) { 159 ["test"]=> 160 string(5) "hello" 161 } 162} 163array(1) { 164 ["test"]=> 165 string(5) "hello" 166} 167array(1) { 168 ["section.test"]=> 169 string(5) "hello" 170} 171array(1) { 172 ["section"]=> 173 array(1) { 174 ["section.test"]=> 175 string(5) "hello" 176 } 177} 178array(1) { 179 ["section"]=> 180 array(1) { 181 [1]=> 182 string(1) "2" 183 } 184} 185array(1) { 186 [1]=> 187 string(1) "2" 188} 189array(1) { 190 ["test"]=> 191 string(5) "test4" 192} 193array(1) { 194 ["section1"]=> 195 array(1) { 196 ["name"]=> 197 string(5) "value" 198 } 199} 200array(3) { 201 ["foo"]=> 202 string(4) "bar1" 203 ["_foo"]=> 204 string(4) "bar2" 205 ["foo_"]=> 206 string(4) "bar3" 207} 208array(3) { 209 ["foo"]=> 210 string(4) "bar1" 211 ["_foo"]=> 212 string(4) "bar2" 213 ["foo_"]=> 214 string(4) "bar3" 215} 216Done 217