Forum Moderators: coopster
I'm generating an INI file from a database, and one of the fields is Office, and the system code for this resource is OFF. The problem is that "OFF" is used as a key in other tables, so I can't really change it.
It appears that OFF is a php reserved word, because when I try to parse the INI file to get the values I need to look up in the other tables, I get Error parsing resource_types.ini and the hwole thing fails.
Any ideas on this? or how to workaround?
Yeah, I didn't see it on the list of words either, but if I comment out the line writing "OFF" to the ini, it works fine, and if I use backticks around the word OFF it also works.
Note that the error isn't in the ini file-- it's from parse_ini_file(). Here's a sample ini file that will show you what I mean:
; test ini file
[Offices]
TEST = new value
OFF = my value
then:
<?php
$test = parse_ini_file("test.ini");
var_dump($test);
?>
At this point I think I'm just going to write the backticks around the key part of the ini file, then strip those backticks after I parse the ini. But it just seems like a hack and I'd rather have it working properly!
Thanks
From [us2.php.net...]
" Note: There are reserved words which must not be used as keys for ini files. These include: null, yes, no, true, false, on, off, none. Values null, no and false results in "", yes and true results in "1". Characters {}¦&~![()^" must not be used anywhere in the key and have a special meaning in the value. "