|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-02-03 08:56 UTC] thasypher at gmail dot com
Description:
------------
PHP seems to be unable to handle strings with certain signs (#$%) in an INI file parsed with parse_ini_file.
It throws a warning while doing that.
Even though normally you would quote strings to overcome this issue, the ConfigParser implementation of Python (for instance) does not do this.
Test script:
---------------
print_r(parse_ini_file('file.ini', true, ));
Expected result:
----------------
An ini file with certain characters will throw a warning and may not be parsed completely.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 18:00:01 2025 UTC |
A sample INI could be: ---- [data] test_case = 1 some_server = localhost more_stuff = 8.8.8.8 [test] somevalue = 1 password_server.domain.tld = h1b{k&Tx$jt2 ---- In this case, it throws an "Error parsing <filename> on line 8. Also with: --- [test] some_thing = R3iDn3!rj3j --- it will fail. So ISTM that special characters are causing issues in the parse_ini_file.I don't know if it will help to find the cause of this bug, but I found that enclosing the string with quotes solves the problem : ini file: --------- [test] some_thing = "R3iDn3!rj3j" test file: ---------- <?php print_r(parse_ini_file('bug.ini', true )); result (as expected): ---------------------- Array ( [test] => Array ( [some_thing] => R3iDn3!rj3j ) )