Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.12

Bug #6441 true and false literals should be parsed appropriately
Submitted: 2006-01-07 16:25 UTC Modified: 2006-12-16 07:53 UTC
From: shannah at sfu dot ca Assigned: aashley
Status: Closed Package: Config
PHP Version: 4.4.1 OS: All
Roadmaps: (Not assigned)    
Subscription  


 [2006-01-07 16:25 UTC] shannah at sfu dot ca
Description: ------------ true and false values should be parsed as boolean values rather than the strings "true" and "false". The parse_ini_file() function works this way. For example, given the ini file: val1 = true val2 = false val3 = True val4 = False val5 = TRUE val6 = FALSE val7 = "true" val8 = "false" And the php script to parse it: <? $res = parse_ini_file("ini_file.ini"); var_dump($res); ?> We see the output: array(8) { ["val1"]=> string(1) "1" ["val2"]=> string(0) "" ["val3"]=> string(1) "1" ["val4"]=> string(0) "" ["val5"]=> string(1) "1" ["val6"]=> string(0) "" ["val7"]=> string(4) "true" ["val8"]=> string(5) "false" } However, if we use Config.php to parse the same ini file using the following script: require_once 'Config.php'; $configLoader =& new Config(); $conf_obj = $configLoader->parseConfig( "ini_file.ini", 'inicommented'); $temp = $conf_obj->toArray(); $conf = $temp['root']; var_dump($conf); We obtain the output: array(8) { ["val1"]=> string(4) "true" ["val2"]=> string(5) "false" ["val3"]=> string(4) "True" ["val4"]=> string(5) "False" ["val5"]=> string(4) "TRUE" ["val6"]=> string(5) "FALSE" ["val7"]=> string(4) "true" ["val8"]=> string(5) "false" } Test script: --------------- Ini file: ========= val1 = true val2 = false val3 = True val4 = False val5 = TRUE val6 = FALSE val7 = "true" val8 = "false" Test script: ============ require_once 'Config.php'; $configLoader =& new Config(); $conf_obj = $configLoader->parseConfig( "ini_file.ini", 'inicommented'); $temp = $conf_obj->toArray(); $conf = $temp['root']; var_dump($conf); Expected result: ---------------- array(8) { ["val1"]=> string(1) "1" ["val2"]=> string(0) "" ["val3"]=> string(1) "1" ["val4"]=> string(0) "" ["val5"]=> string(1) "1" ["val6"]=> string(0) "" ["val7"]=> string(4) "true" ["val8"]=> string(5) "false" } Actual result: -------------- array(8) { ["val1"]=> string(4) "true" ["val2"]=> string(5) "false" ["val3"]=> string(4) "True" ["val4"]=> string(5) "False" ["val5"]=> string(4) "TRUE" ["val6"]=> string(5) "FALSE" ["val7"]=> string(4) "true" ["val8"]=> string(5) "false" }

Comments

 [2006-02-13 19:48 UTC] aashley at php dot net
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.