Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Parse INI File gives me error about equal sign

Tags:

php

ini

I'm trying to parse out an INI file that has a URL as one of the variables to parse. Problem is, the URL contains a '=' in it, and parse_ini_file spits out an error. I tried to escape the character, but to no avail. Does this happen to anybody else? And if so, has anybody fixed it?

like image 356
psion Avatar asked Feb 28 '11 18:02

psion


2 Answers

Have you enclosed the value in quotes? It shouldn't be a problem to have = in the value as long as you have quotes around your value. Example:

key1="http://www.google.com?q=test";
like image 81
Martin Avatar answered Oct 13 '22 01:10

Martin


much better would be use INI_SCANNER_RAW as 3rd parameter of parse_ini_file

parse_ini_file($file, true, INI_SCANNER_RAW);
like image 30
Kamil Karkus Avatar answered Oct 13 '22 01:10

Kamil Karkus