Re: parse_ini_file problem [SOLVED]

From: Date: Thu, 27 Aug 2009 14:28:40 +0000
Subject: Re: parse_ini_file problem [SOLVED]
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-297370@lists.php.net to get a copy of this message
Hi Jim, Cheers for the reply. I had to swap the quotes around to get it running on the windows command line. This from the 5.3.0 machine that does not parse: ------------ C:\wamp\www\digishop\install\lang>C:\wamp\bin\php\php5.3.0\php -r "print_r(parse_ini_file('1-ISO-8859-1.ini.php'));" PHP Warning: parse error in 1-ISO-8859-1.ini.php on line 1 in Command line code on line 1 Warning: parse error in 1-ISO-8859-1.ini.php on line 1 in Command line code on line 1 ------------ This is from the 5.2.5 machine that parses properly: ------------ C:\wamp\www\digishop\install\lang>C:\wamp\bin\php\php5.2.5\php -r "print_r(parse_ini_file('"1-ISO-8859-1.ini.php'));" Array (
    [btn_step_complete] => Ok, I Have Completed This Step
    [btn_next] => Next
    [btn_cancel] => Cancel
... . . ------------ The php warning displayed is exac php -v on the 5.3.0 machine: ------------ C:\wamp\www\digishop\install\lang>C:\wamp\bin\php\php5.3.0\php -v PHP 5.3.0 (cli) (built: Jun 29 2009 21:25:23) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies ------------ php -v on the 5.3.0 machine: ------------ C:\wamp\www\digishop\install\lang>C:\wamp\bin\php\php5.2.5\php -v PHP 5.2.5 (cli) (built: Nov 8 2007 23:18:51) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies ------------ So I checked the changelog from 5.2.5 to 5.3.0:
           o Added 3rd optional parameter to parse_ini_file() to specify the scanning mode of INI_SCANNER_NORMAL or INI_SCANNER_RAW. In raw mode option values and section values are treated as-is.
     * Added parse_ini_string() function. (grange at lemonde dot fr, Arnaud)
     * Fixed bug #46347 (parse_ini_file() doesn't support * in keys). (Nuno)
     * Fixed bug #45384 (parse_ini_file will result in parse error with no trailing newline). (Arnaud)
     * Fixed bug #44842 (parse_ini_file keys that start/end with underscore). (Arnaud)
     * Fixed bug #44575 (parse_ini_file comment # line problems). (Arnaud)
     * Fixed bug #45956 (parse_ini_file() does not return false with syntax errors in parsed file). (Jani)
So I installed PHP 5.2.5 and it worked. Thanks to everyone for their help! Richard Lee Jim Lucas wrote:
Richard H Lee wrote:
Hi all, I think I'm having a problem with parse_ini_file in php. I am using wamp on two machines. I'm installing a Digishop e-commerce package. The blah.ini.php file starts with ---------------- <?php die ?> [SOMETITLE] some_setting="Ok, I Have Completed This Step" another_setting="Next" .. .. .. ---------------- On one machine which uses php 5.2.5 it parses the file fine and installs properly But on another machine which use 5.3.0 i get the error Warning: parse error in blah.ini.php on line 1 in myparser.php on line 81 On the 5.3.0 if I remove the <?php die ?> it works fine. But it still does not install the sofware properly. I get the feeling php on the 5.3.0 marchine is parsing the file differently to the 5.2.5. I doubt anything has changed between the versions. I also compared the phpinfos between the two setups but could not see anything outstanding. Have any of you guys seen this behaviour before? Cheers, Richard
I would write a little line to your cli like this php -r 'print_r(parse_ini_file("/path/to/your/ini.file.php"));' see if the output is different. If it is, then you know that the two versions are doing something different. If you find that the output is different and you have more questions please provide the output from "php -v" from both machines and we might be able to help further.


« previous php.general (#297370) next »