snehal
snehal

Reputation: 449

How to Handle Special character in config.ini file as variable in php

I have created one config.ini file with help of this

my file contain:

[first_section]
sourcepath="C:\wamp\www\mydata\"
filetype="csv"
Product="Product"
A & E="A & E"

And My.Php file is

$ini_array = parse_ini_file("config.ini", true);

print_r($ini_array);

when i call this php program it giving following Error

Warning: syntax error, unexpected '&' in config.ini on  in C:\wamp\www\mydata\my.php on line 9

I know i cant use special characters in variable . but i have to use this only .

so not getting how to do. Can any one Help me on this.

Thank you

Upvotes: 2

Views: 11157

Answers (1)

Amal Murali
Amal Murali

Reputation: 76656

Nope, characters like & can't be used as ini keys.

From the PHP Manual:

Characters ?{}|&~![()^" must not be used anywhere in the key and have a special meaning in the value.

See the documentation: parse_ini_file

Upvotes: 4

Related Questions