Reputation: 16719
INI data looks like this:
[datasources]
live.dsn = "mysql:host=localhost;dbname=main"
live.user = "root"
live.pass =
I'm using parse_ini_file()
.
INI_SCANNER_RAW
live.dsn
is parsed incorrectly ("mysql:host
)INI_SCANNER_NORMAL
the value of live.dsn
is correct But I can't use INI_SCANNER_NORMAL
because then it will also replace constants, "on" with 1
and so on (don't want that)... Is there any fix or do I have to create my own parser?
I'm using PHP 5.3.
Upvotes: 0
Views: 337
Reputation: 23787
var_dump(parse_ini_string('[datasources]
live.dsn = "mysql:host=localhost;dbname=main"
live.user = "root"', false, INI_SCANNER_RAW));
=>
array(2) {
["live.dsn"]=>
string(32) "mysql:host=localhost;dbname=main"
["live.user"]=>
string(4) "root"
}
I am unable to reproduce it. (It also doesn't work for parse_ini_file
.) It works in PHP 5.3 and PHP trunk...
I see that this was a bug in older PHP versions, see https://bugs.php.net/bug.php?id=51094 . Simply upgrade, then it should work. If you're unable to upgrade, you really have to write your own ini parser.
Upvotes: 1