dousao6313 2018-02-16 12:07
浏览 91
已采纳

有没有parse_ini_file()的特殊行为我应该知道吗? [关闭]

I have a quite big INI file (around 100kb and over 2000 lines) which I am trying to parse with PHP: $ini_array = parse_ini_file("config.ini");

But the function throw a warning: PHP Warning: syntax error, unexpected '(' in config.ini on line 1334 in ...

Looking at line 1334 won't show any syntax error. Then I read this answer :

Short answer:

Don't trust the line numbers, look for a syntax error in the lines before the line mentioned in the error.

I am confident that there is no error in the file because its used in production by an other tool wrote in Pascal.

So,

  • How I could check the file manually for errors ?

  • And if no syntax error exist in the file, is there a behavior of parse_ini_file() I should be aware of ?

  • 写回答

2条回答 默认 最新

  • dongnaota6386 2018-02-16 13:12
    关注

    I found in the PHP manual :

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

    From PHP 5.3.0 we can set a third parameter scanner_mode. So calling parse_ini_file() with INI_SCANNER_RAW as third parameter did the trick - the function do not evaluate values.

    By default the function use the INI_SCANNER_NORMAL mode and evaluate values.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛