代码之家  ›  专栏  ›  技术社区  ›  XMen

在php中创建配置文件

  •  0
  • XMen  · 技术社区  · 16 年前

    如何实现配置文件的生成。

    拉胡尔

    3 回复  |  直到 16 年前
        1
  •  3
  •   Gaurav Jassal    16 年前

    您可以为您的项目创建一个INI配置文件,并使用php parse_INI_file函数对其进行解析。

    http://php.net/manual/en/function.parse-ini-file.php

    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"
    

    下面是PHP配置模式的另一个示例

    h++p://www.ibm.com/developerworks/library/os-php-config/index.html

        2
  •  1
  •   rabi shankar shaw    14 年前
    <?php
    
    if ( ! defined('EXT')){
    exit('Invalid file request');
    }
    
    $conf['app_version'] = "167";
    $conf['license_number'] = "";
    $conf['debug'] = "1";
    $conf['install_lock'] = "1";
    $conf['db_hostname'] = "localhost";
    $conf['db_username'] = "username";
    $conf['db_password'] = "password";
    $conf['db_name'] = "sample";
    $conf['db_type'] = "mysql";
    $conf['db_prefix'] = "exp";
    $conf['db_conntype'] = "0";
    $conf['system_folder'] = "system";
    $conf['cp_url'] = "http://sample:8888/system/index.php";
    $conf['doc_url'] = "http://expressionengine.com/docs/";
    $conf['cookie_prefix'] = "";
    $conf['is_system_on'] = "y";
    $conf['allow_extensions'] = "n";
    $conf['multiple_sites_enabled'] = "n";
    ?>
    
        3
  •  0
  •   XMen    16 年前

    我做了一个数组

        $config = array (
            "{b0ff543d-d294-42c8-83eb-d72161ec6771}"  => '/var/www/youngib/rahul/'
        );
    $source=$config[$_REQUEST['applicationid']];
    

    拉胡尔

    推荐文章