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条)

报告相同问题?

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装