Edit report at https://bugs.php.net/bug.php?id=38409&edit=1
ID: 38409
Comment by: adria dot cidre at gmail dot com
Reported by: yury at shurup dot com
Summary: parse_ini_file() looses the type of booleans
Status: Open
Type: Feature/Change Request
Package: PHP options/info functions
Operating System: Ubuntu 8.04.1
PHP Version: 5.2.4-2ubuntu5.4 with Suhosin-Patch 0.9.6.2 (cli)
Block user comment: N
Private report: N
New Comment:
Still not working on Centos over PHP 5.3.10
Previous Comments:
------------------------------------------------------------------------
[2011-12-19 19:21:23] pwinnski at gmail dot com
PHP 5.3.6 on Centos. Still not fixed, so I must explicitly cast to boolean in
the
code that reads the ini file.
------------------------------------------------------------------------
[2010-08-31 23:33:03] guy dot paddock at redbottledesign dot com
Hrm, it also looks like there's a similar problem for integers -- they become
integer strings, so is_int() returns FALSE on them.
Why doesn't parse_ini_file() translate values to the appropriate type?
------------------------------------------------------------------------
[2010-08-31 17:07:06] guy dot paddock at redbottledesign dot com
I also second the fact that parse_ini_file() should parse booleans as boolean
types, rather than strings. In my application, the values returned from parsing
the INI file are checked to ensure that they are the correct type (string,
bool, int, etc). That way, if the user accidentally typed the wrong value in
for a setting, they are presented with the appropriate error message, rather
than having their value interpreted incorrectly.
Unfortunately, the way that parse_ini_file() parses booleans, it converts
"TRUE" and "FALSE" into "1" or an empty string "", which means that is_bool()
returns FALSE. I understand perfectly that is_bool() is intended only to
determine if a variable really is a boolean -- my problem is not with that
function. My problem is with parse_ini_file()'s counter-intuitive behavior of
not parsing boolean values into a boolean type. Why else would we want it
interpreting boolean constants in the first place?
------------------------------------------------------------------------
[2008-12-12 14:43:42] yury at shurup dot com
It is very sad that this bug is still not classified, fixed and is perfectly
reproducible after about 2 years since my original posting. I hope I would be
able to hack on the sources some day but surely not during the next year to
come.
------------------------------------------------------------------------
[2008-12-12 13:14:15] philipp dot kempgen at amooma dot de
In addition to that I want NULL (unquoted) to be of type NULL.
Unquoted integers => int, unquoted floating point numbers =>
float/double.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=38409
--
Edit this bug report at https://bugs.php.net/bug.php?id=38409&edit=1