简体   繁体   English

如何将config.ini文件中的特殊字符作为php中的变量进行处理

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

I have created one config.ini file with help of this 我已经在帮助下创建了一个config.ini文件

my file contain: 我的文件包含:

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

And My.Php file is My.Php文件是

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

print_r($ini_array);

when i call this php program it giving following Error 当我调用此php程序时,出现以下错误

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 . 我知道我不能在variable中使用特殊字符。 but i have to use this only . 但我只用这个。

so not getting how to do. 所以不知道怎么做。 Can any one Help me on this. 谁可以帮我这个事。

Thank you 谢谢

Nope, characters like & can't be used as ini keys. 不会, &字符不能用作ini键。

From the PHP Manual: 从PHP手册:

Characters ?{}|&~![()^" must not be used anywhere in the key and have a special meaning in the value. 字符?{}|&~![()^"不能在键的任何位置使用,并且在值中具有特殊含义。

See the documentation: parse_ini_file 请参阅文档: parse_ini_file

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM