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