如何使用PHP读取自定义格式的配置文件 [英] how to read custom formatted config file using PHP

查看:179
本文介绍了如何使用PHP读取自定义格式的配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想使用PHP解析以下类型的格式化配置文件。

 config ' 环境''MyInfo' 
选项 ' 名称''0'
选项 ' 移动''0'
选项 ' EMAIL''0'





如果我们使用parse_ini_file()函数,那么它将需要特定格式的ini文件。请建议如何解析这些文件。



Regds

解决方案

你必须阅读文本文件(您可以在此页面中找到几种方法:使用PHP读取文件的正确方法 [ ^ ]然后解析自己阅读内容(这里的有用信息:在Stack Overflow上PHP - 解析txt文件 [ ^ ]。

Hi,

I want to parse following type of formatted config file using PHP.

config 'Environment' 'MyInfo'
    option 'Name' '0'
    option 'Mobile' '0'
    option 'EMAIL' '0'



if we use parse_ini_file() function then it would require ini file in specific format. Please suggest how to parse such files.

Regds

解决方案

You have to read the text file (you may find several approaches discussed in this page: "The right way to read files with PHP"[^] and then parse yourself the read content (useful info here: "PHP - parsing a txt file" at Stack Overflow[^].


这篇关于如何使用PHP读取自定义格式的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆