解析配置文件:

parse_ini_file

  

类似解析php.ini文件样

配置文件内容如下:

Example #1 sample.ini 的内容

; This is a sample configuration file
; Comments start with ';', as in php.ini [first_section]
one = 1
five = 5
animal = BIRD [second_section]
path = "/usr/local/bin"
URL = "http://www.example.com/~username" [third_section]
phpversion[] = "5.0"
phpversion[] = "5.1"
phpversion[] = "5.2"
phpversion[] = "5.3"

  

解析:

// Parse without sections
$ini_array = parse_ini_file("sample.ini");
print_r($ini_array); // Parse with sections
$ini_array = parse_ini_file("sample.ini", true);
print_r($ini_array);

  

结果:

Array
(
[one] => 1
[five] => 5
[animal] => Dodo bird
[path] => /usr/local/bin
[URL] => http://www.example.com/~username
[phpversion] => Array
(
[0] => 5.0
[1] => 5.1
[2] => 5.2
[3] => 5.3
) )
Array
(
[first_section] => Array
(
[one] => 1
[five] => 5
[animal] => Dodo bird
) [second_section] => Array
(
[path] => /usr/local/bin
[URL] => http://www.example.com/~username
) [third_section] => Array
(
[phpversion] => Array
(
[0] => 5.0
[1] => 5.1
[2] => 5.2
[3] => 5.3
) ) )

  

PHP的 parse_ini_file 解析配置文件的更多相关文章

  1. php解析配置文件

    php解析配置文件 标签(空格分隔): php .ini格式 ![](https://img2020.cnblogs.com/blog/1458583/202003/1458583-202003301 ...

  2. [Python]ConfigParser解析配置文件

    近期发现非常多接口配置都硬编码在souce file中了,于是就看了下python怎么解析配置文件,重构下这一块. 这个应该是早就要作的... 配置文件: [mysqld] user = mysql ...

  3. 【开源.NET】轻量级内容管理框架Grissom.CMS(第三篇解析配置文件和数据以转换成 sql)

    该篇是 Grissom.CMS 框架系列文章的第三篇, 主要介绍框架用到的核心库 EasyJsonToSql, 把标准的配置文件和数据结构解析成可执行的 sql. 该框架能实现自动化增删改查得益于 E ...

  4. mybatis源码-解析配置文件(四-1)之配置文件Mapper解析(cache)

    目录 1. 简介 2. 解析 3 StrictMap 3.1 区别HashMap:键必须为String 3.2 区别HashMap:多了成员变量 name 3.3 区别HashMap:key 的处理多 ...

  5. mybatis源码-解析配置文件(四)之配置文件Mapper解析

    在 mybatis源码-解析配置文件(三)之配置文件Configuration解析 中, 讲解了 Configuration 是如何解析的. 其中, mappers作为configuration节点的 ...

  6. mybatis源码-解析配置文件(三)之配置文件Configuration解析

    目录 1. 简介 1.1 系列内容 1.2 适合对象 1.3 本文内容 2. 配置文件 2.1 mysql.properties 2.2 mybatis-config.xml 3. Configura ...

  7. mybatis源码-解析配置文件(二)之解析的流程

    目录 1. 简介 2. 配置文件解析流程分析 2.1 调用 2.2 解析的目的 2.3 XML 解析流程 2.3.1 build(parser) 2.3.2 new XMLConfigBuilder( ...

  8. mybatis源码-解析配置文件(一)之XML的DOM解析方式

    目录 简介 Java 中 XML 文件解析 解析方式 DOM 解析 XML 新建 XML 文件 DOM 操作相关类 Java 读取 XML 文件 一起学 mybatis @ 简介 在之前的文章< ...

  9. Redis(四):解析配置文件redis.conf

    解析配置文件redis.conf目录导航: 它在哪 Units单位 INCLUDES包含 GENERAL通用 SNAPSHOTTING快照 REPLICATION复制 SECURITY安全 LIMIT ...

随机推荐

  1. NSCTF 2017-pwn2

    目录 程序基本信息 程序漏洞 整体思路 exp脚本 发现的问题 内容参考 程序基本信息 32位动态链接程序,开启了数据段不可执行以及栈溢出保护 程序漏洞 在函数中sub_80487fa中有一个格式化字 ...

  2. css 文本省略号设置

    本文推荐2种方法. 1. css tip:只兼容chrome内核的浏览器.ff不支持. .box { overflow: hidden; /* 溢出时不显示溢出的内容 */ text-overflow ...

  3. CAP C3-2分析

    一致性 可用性 分区容错性 <Hadoop构建数据仓库实践> p84

  4. patch工具的使用

    1. 最简用法 patch -p1 < jello.patch

  5. Android架构(一)MVP架构在Android中的实践

    Android架构(一)MVP架构在Android中的实践 https://www.300168.com/yidong/show-2790.html   核心提示:为什么要重视程序的架构设计 对程序进 ...

  6. std::wstring std::string w2m m2w

    static std::wstring m2w(std::string ch, unsigned int CodePage = CP_ACP) { if (ch.empty())return L&qu ...

  7. docker之redis使用

    #拉取redis > docker pull redis:latest latest: Pulling from library/redis 8d691f585fa8: Pull complet ...

  8. 集合循环删除问题-报错java.util.ConcurrentModificationException解析

    java.util.ConcurrentModificationException 异常问题详解 环境:JDK 1.8.0_111 在Java开发过程中,使用iterator遍历集合的同时对集合进行修 ...

  9. PAT 甲级 1053 Path of Equal Weight (30 分)(dfs,vector内元素排序,有一小坑点)

    1053 Path of Equal Weight (30 分)   Given a non-empty tree with root R, and with weight W​i​​ assigne ...

  10. Pyhthon3之使用__slots__

    正常情况下,我们定义了一个class,创建了一个class实例后,我们可以给该实例绑定任何属性和方法,这就是动态语言的灵活性.先定义class: >>> class Student( ...