doudong0425 2011-08-10 21:34
浏览 93
已采纳

使用PHP解析* .ini文件时丢失布尔值

Just tried to make my own config handler in PHP, utilizing the native PHP parse_ini_file-function. I did just notice that all of my config entries where the value is a boolean - true/false are messed up, along with most other config entries being typecasted to strings.

Apparently, this is a well-known issue already: http://www.php.net/manual/en/function.parse-ini-file.php#100851

So what is the appropriate workaround?
It's really neat to utilize non-PHP-configs, which makes it dead easy for non-developers to change a value when necessary, so I would love to keep the *.ini-based configs.

  • 写回答

2条回答 默认 最新

  • doukenqiong0588 2011-08-10 21:50
    关注

    I guess the most simple solution to the problem is to just use your own config handler. Either write a ini class or download a free one (ini format is extremely simple).

    But I would recommend storing your config in xml if you want interoperability. Every modern programming language has tons of XML parsers available or build-in. Also you gain more flexibility in your settings structure. And you can easily make you settings format typesafe.

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

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)