zoukankan      html  css  js  c++  java
  • PHP的 parse_ini_file 解析配置文件

    解析配置文件:

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

      

  • 相关阅读:
    jdk动态代理
    mysql-索引方案
    闭包的有点以及出现的内存泄露2016/4/12
    表单2016/4/8
    cursor
    同一个事件绑定不同的函数
    a:link visited hover active
    对于属性操作,加入属性,移除属性
    offset获取位置
    清除浮动6中方法
  • 原文地址:https://www.cnblogs.com/echojson/p/10968910.html
Copyright © 2011-2022 走看看