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 21:25 UTC
From: shannah at sfu dot ca Assigned: aashley
Status: Closed Package: Config
PHP Version: 4.4.1 OS: All
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 29 + 7 = ?

 
 [2006-01-07 21: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-14 00: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.