PHP Classes

parse-ini_file error when value contains equal sign

Recommend this page to a friend!

      PHP INI Editor Class  >  All threads  >  parse-ini_file error when value...  >  (Un) Subscribe thread alerts  
Subject:parse-ini_file error when value...
Summary:please use INI_SCANNER_RAW as 3rd parameter
Messages:5
Author:Jean-Luc Piquard
Date:2017-04-03 07:52:20
 

  1. parse-ini_file error when value...   Reply   Report abuse  
Picture of Jean-Luc Piquard Jean-Luc Piquard - 2017-04-03 07:52:20
Reading an ini file containing an equal sign in Value produces a parse_ini_file Error
Simply added INI_SCANNER_RAW as the 3rd Parameter of parse_ini_file line 356 in IniEditorClass.php solved that Error:

Change Line 356:
$conf = parse_ini_file($this->ini_file, true);
into:
$conf = parse_ini_file($this->ini_file, true, INI_SCANNER_RAW);


  2. Re: parse-ini_file error when value...   Reply   Report abuse  
Picture of Jean-Luc Piquard Jean-Luc Piquard - 2017-04-03 22:24:04 - In reply to message 1 from Jean-Luc Piquard
to avoid "Call to undefined function multiexplode()" Error,
please change also line 153:
$conf = multiexplode(array('#',';'), $key);
into:
$conf = $this->multiexplode(array('#',';'), $key);

I hope my contribution will help ...

(config: PHP 7.1.3 /Wamp Server 3.0.8)

  3. Re: parse-ini_file error when value...   Reply   Report abuse  
Picture of Blupixel IT Srl Blupixel IT Srl - 2017-04-10 08:44:03 - In reply to message 2 from Jean-Luc Piquard
Thank you much Juan,
I'll check and fix the error and add a new version of the class.
Just a qustion: In your ini file, the value (containing the = sign) was wrapped into double quotes (ex. field = "myvalue=new")?

Thank you!

Best regards

  4. Re: parse-ini_file error when value...   Reply   Report abuse  
Picture of Jean-Luc Piquard Jean-Luc Piquard - 2017-04-10 10:25:04 - In reply to message 3 from Blupixel IT Srl
no, because that "ini" file is in fact a configuration File created by an Oracle PeopleSoft Application. If we wrap it between double-quotes, it will not be readeable by the application.
e.g.
the problematic line is:
Remote Administration Password={V1.1}7m4OtVwXFNyLc1j6pZG69Q==

the Password in that line is generated by java keytool utility...

but using INI_SCANNER_RAW solved the problem ;-)

  5. Re: parse-ini_file error when value...   Reply   Report abuse  
Picture of Blupixel IT Srl Blupixel IT Srl - 2017-04-14 14:00:17 - In reply to message 4 from Jean-Luc Piquard
Thank you for your patience and work.
I've updated the class with an additional method to select the scanner mode.
With this command, before printing the form, you can change the scanner mode when parsing the ini file (see sample.php for updated example)

// set different Scanner Mode (optional)
$ini_editor->setScannerMode(INI_SCANNER_RAW);

If you have other problems or requests, let us know.

Happy coding!