1--TEST-- 2parse_ini_file() tests 3--ENV-- 4basicval=FUBAR_VARIABLE 5basicqval=FUBAR_QUOTES_VARIABLE 6falsyval=false 7emptyval= 8--INI-- 9INI:WITH:COLON=ini_with_colon 10--FILE-- 11<?php 12 13$ini_file = __DIR__."/parse_ini_basic.data"; 14 15define('TEST_CONSTANT', 'this_is_test_constant'); 16 17var_dump(parse_ini_file($ini_file, 1)); 18 19echo "Done.\n"; 20?> 21--EXPECT-- 22array(29) { 23 ["basic"]=> 24 array(15) { 25 ["basicval"]=> 26 string(3) "bar" 27 ["longval"]=> 28 string(5) "12345" 29 ["with.dot"]=> 30 string(7) "fooobar" 31 ["boolon"]=> 32 string(1) "1" 33 ["booltrue"]=> 34 string(1) "1" 35 ["boolyes"]=> 36 string(1) "1" 37 ["booloff"]=> 38 string(0) "" 39 ["boolfalse"]=> 40 string(0) "" 41 ["boolnone"]=> 42 string(0) "" 43 ["boolno"]=> 44 string(0) "" 45 ["string"]=> 46 string(34) "asdadfsdjkslkj ¡@£$$ { }[ ]/%#¤" 47 ["sqstring"]=> 48 string(14) "adsasdadasdasd" 49 ["dqstring"]=> 50 string(51) "asdadfsdjkslkj ¡@£$$ { } !^~|¥¥{[()/)&/% ¤ # #" 51 ["php_constant"]=> 52 string(1) "2" 53 ["user_constant"]=> 54 string(21) "this_is_test_constant" 55 } 56 ["basic with whitespace"]=> 57 array(13) { 58 ["basicval"]=> 59 string(3) "bar" 60 ["longval"]=> 61 string(5) "12345" 62 ["with.dot"]=> 63 string(7) "fooobar" 64 ["boolon"]=> 65 string(1) "1" 66 ["booltrue"]=> 67 string(1) "1" 68 ["boolyes"]=> 69 string(1) "1" 70 ["booloff"]=> 71 string(0) "" 72 ["boolfalse"]=> 73 string(0) "" 74 ["boolnone"]=> 75 string(0) "" 76 ["boolno"]=> 77 string(0) "" 78 ["sqstring"]=> 79 string(14) "adsasdadasdasd" 80 ["dqstring"]=> 81 string(41) "asdadfsdjkslkj ¡@£$$€¥¥{[()/)&/%#¤" 82 ["php_constant"]=> 83 string(1) "2" 84 } 85 ["comments"]=> 86 array(1) { 87 ["somecomment"]=> 88 string(15) "comment follows" 89 } 90 ["variables"]=> 91 array(8) { 92 ["var1"]=> 93 string(14) "FUBAR_VARIABLE" 94 ["var2"]=> 95 string(18) "FUBAR_VARIABLE/foo" 96 ["var3"]=> 97 string(18) "foo/FUBAR_VARIABLE" 98 ["var4"]=> 99 string(22) "foo/FUBAR_VARIABLE/foo" 100 ["quoted_var1"]=> 101 string(21) "FUBAR_QUOTES_VARIABLE" 102 ["quoted_var2"]=> 103 string(25) "FUBAR_QUOTES_VARIABLE/foo" 104 ["quoted_var3"]=> 105 string(25) "foo/FUBAR_QUOTES_VARIABLE" 106 ["quoted_var4"]=> 107 string(29) "foo/FUBAR_QUOTES_VARIABLE/foo" 108 } 109 ["offset values"]=> 110 array(6) { 111 ["foo1"]=> 112 array(2) { 113 [0]=> 114 string(14) "basic offset 1" 115 [1]=> 116 string(14) "basic offset 2" 117 } 118 ["foo2"]=> 119 array(1) { 120 [123]=> 121 string(11) "long offset" 122 } 123 ["foo3"]=> 124 array(1) { 125 ["abc"]=> 126 string(13) "string offset" 127 } 128 ["foo4"]=> 129 array(4) { 130 [0]=> 131 string(15) "quoted offset 1" 132 [" "]=> 133 string(15) "quoted offset 2" 134 ["sqfoobar"]=> 135 string(20) "quoted string offset" 136 ["dqfoobar"]=> 137 string(20) "single quoted offset" 138 } 139 ["foo6"]=> 140 array(4) { 141 ["FUBAR_VARIABLE"]=> 142 string(8) "variable" 143 ["FUBAR_VARIABLE/foo"]=> 144 string(22) "variable with string 1" 145 ["foo/FUBAR_VARIABLE"]=> 146 string(22) "variable with string 2" 147 ["foo/FUBAR_VARIABLE/foo"]=> 148 string(22) "variable with string 3" 149 } 150 ["foo7"]=> 151 array(4) { 152 ["FUBAR_QUOTES_VARIABLE"]=> 153 string(17) "quoted variable 1" 154 ["FUBAR_QUOTES_VARIABLE/foo"]=> 155 string(17) "quoted variable 2" 156 ["foo/FUBAR_QUOTES_VARIABLE"]=> 157 string(17) "quoted variable 3" 158 ["foo/FUBAR_QUOTES_VARIABLE/foo"]=> 159 string(17) "quoted variable 4" 160 } 161 } 162 ["non value"]=> 163 array(4) { 164 ["novalue_option1"]=> 165 string(0) "" 166 ["novalue_option2"]=> 167 string(0) "" 168 ["novalue_option3"]=> 169 string(0) "" 170 ["novalue_option4"]=> 171 array(3) { 172 [0]=> 173 string(0) "" 174 [1]=> 175 string(0) "" 176 [2]=> 177 string(0) "" 178 } 179 } 180 ["Quoted strings and variables in sections"]=> 181 array(0) { 182 } 183 ["FUBAR_VARIABLE"]=> 184 array(0) { 185 } 186 ["foo"]=> 187 array(0) { 188 } 189 ["FUBAR_VARIABLE/foo"]=> 190 array(0) { 191 } 192 ["foo/FUBAR_VARIABLE"]=> 193 array(0) { 194 } 195 ["foo/FUBAR_VARIABLE/foo"]=> 196 array(0) { 197 } 198 ["FUBAR_QUOTES_VARIABLE"]=> 199 array(0) { 200 } 201 ["FUBAR_QUOTES_VARIABLE/foo"]=> 202 array(0) { 203 } 204 ["foo/FUBAR_QUOTES_VARIABLE"]=> 205 array(0) { 206 } 207 ["foo/FUBAR_QUOTES_VARIABLE/foo"]=> 208 array(0) { 209 } 210 ["PATH=FUBAR_VARIABLE/no/quotes"]=> 211 array(0) { 212 } 213 ["PATH=FUBAR_VARIABLE/all/quoted"]=> 214 array(0) { 215 } 216 ["01"]=> 217 array(2) { 218 ["e"]=> 219 string(1) "e" 220 ["f"]=> 221 string(1) "f" 222 } 223 ["02"]=> 224 array(2) { 225 ["g"]=> 226 string(1) "g" 227 ["h"]=> 228 string(1) "h" 229 } 230 [1]=> 231 array(2) { 232 ["a"]=> 233 string(1) "a" 234 ["b"]=> 235 string(1) "b" 236 } 237 [2]=> 238 array(2) { 239 ["c"]=> 240 string(1) "c" 241 ["d"]=> 242 string(1) "d" 243 } 244 ["0815"]=> 245 array(1) { 246 ["bla"]=> 247 string(3) "bla" 248 } 249 ["bug #43923"]=> 250 array(3) { 251 ["curly1"]=> 252 string(1) "{" 253 ["curly2"]=> 254 string(1) "{" 255 ["curly3"]=> 256 string(1) "{" 257 } 258 ["bug #44019"]=> 259 array(6) { 260 ["concatenation_before"]=> 261 string(37) "this_is_test_constant+some_text_after" 262 ["concatenation_middle"]=> 263 string(54) "some_text_before+this_is_test_constant+some_text_after" 264 ["concatenation_after"]=> 265 string(38) "some_text_before+this_is_test_constant" 266 ["concatenation_nows_before"]=> 267 string(37) "this_is_test_constant+some_text_after" 268 ["concatenation_nows_middle"]=> 269 string(54) "some_text_before+this_is_test_constant+some_text_after" 270 ["concatenation_nows_after"]=> 271 string(38) "some_text_before+this_is_test_constant" 272 } 273 ["bug #43915"]=> 274 array(3) { 275 ["ini_with-hyphen"]=> 276 string(26) "with hyphen and underscore" 277 ["ini.with-hyphen"]=> 278 string(14) "dot and hyphen" 279 ["ini-with.hyphen"]=> 280 string(14) "hyphen and dot" 281 } 282 ["windows paths"]=> 283 array(2) { 284 ["winpath1"]=> 285 string(69) "c:\some windows\path\test\new\r\quote " here\single ' quote\some more" 286 ["winpath2"]=> 287 string(13) "special case\" 288 } 289 ["characters escaping"]=> 290 array(6) { 291 ["single_quoted"]=> 292 string(28) "She said \Exactly my point\." 293 ["double_quoted"]=> 294 string(28) "She said "Exactly my point"." 295 ["double_quoted_2"]=> 296 string(29) "Use \" to escape double quote" 297 ["double_quoted_multiline"]=> 298 string(20) "Lorem "ipsum" 299 dolor" 300 ["dollar_test"]=> 301 string(7) "${test}" 302 ["unescaped"]=> 303 string(6) "\n\r\t" 304 } 305 ["variable-fallback"]=> 306 array(19) { 307 ["defined1"]=> 308 string(22) "Hello, FUBAR_VARIABLE!" 309 ["defined2"]=> 310 string(14) "FUBAR_VARIABLE" 311 ["falsy"]=> 312 string(5) "false" 313 ["undefined"]=> 314 string(13) "Hello, world!" 315 ["empty"]=> 316 string(3) "foo" 317 ["spaces"]=> 318 string(8) "hi there" 319 ["exclamation"]=> 320 string(21) "no, this is fallback!" 321 ["nested"]=> 322 string(5) "hello" 323 ["hostname"]=> 324 string(14) "localhost:8080" 325 ["outer_quotes"]=> 326 string(7) "foo:bar" 327 ["number_value"]=> 328 string(5) "12345" 329 ["true_value"]=> 330 string(1) "1" 331 ["false_value"]=> 332 string(0) "" 333 ["null_value"]=> 334 string(0) "" 335 ["empty1"]=> 336 string(0) "" 337 ["empty2"]=> 338 string(0) "" 339 ["constant"]=> 340 string(21) "this_is_test_constant" 341 ["INI:WITH:COLON"]=> 342 string(14) "ini_with_colon" 343 ["NONEXISTENT:INI:WITH:COLON"]=> 344 string(8) "fallback" 345 } 346} 347Done. 348