From: yury at shurup dot com Operating system: Windows 2000 SP4 Rollup 2 PHP version: 4.4.3 PHP Bug Type: Filesystem function related Bug description: parse_ini_file() looses the type of booleans
Description: ------------ Hi! I have searched a bug database for the parse_ini_file keyword, but didn't find a releavant report submitted earlier. I am aware of bugs http://bugs.php.net/bug.php?id=18411 http://bugs.php.net/bug.php?id=19575 but I am asking for another thing. The problem is that in the described environment, PHP's parse_ini_file() function looses the type record for booleans and qualifies them either as an empty string for "false" or 1-char string (containing "1") for "true" instead of qualifying them as booleans as it is supposed to be (no relevant docs on this behaviour as well). If this is by design, then IMHO it is absolutely a subject to change and document in future PHP versions, because, YES, you can cast the type from string to bool, BUT what if you don't know that it IS a bool (parsing an abstract INI file)? After all, originally those INI-files came from Windows and everybody should treat them similar to the GetProfile... functions to avoid confusion (an unquoted boolean keyword like in the example below should remain a boolean, while quoted keyword should be treated as a string). In any case it wouldn't hurt and cause incompatibilies with older versions. This is very annoying for someone writing a non-intrusive INI-file parser (which, e.g. would preserve comments, thus operating with parse_ini_file to read and the regular expressions to write out). Reproduce code: --------------- Script ====== $stuff = parse_ini_file($file, true); var_dump($stuff); $a = array(); $a["foo"] = true; $a["bar"] = false; var_dump($a); INI file ======== [foo] bar = false quux = true Expected result: ---------------- ["bar"]=> bool(false) ["quux"]=> bool(true) array(2) { ["foo"]=> bool(true) ["bar"]=> bool(false) } Actual result: -------------- ["bar"]=> string(0) "" ["quux"]=> string(1) "1" array(2) { ["foo"]=> bool(true) ["bar"]=> bool(false) } -- Edit bug report at http://bugs.php.net/?id=38409&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38409&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38409&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38409&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38409&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38409&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38409&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38409&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38409&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38409&r=support Expected behavior: http://bugs.php.net/fix.php?id=38409&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38409&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38409&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38409&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38409&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38409&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38409&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38409&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38409&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38409&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38409&r=mysqlcfg