在php中创建配置文件

时间:2010-10-22 11:48:53

标签: php file configuration

我想创建配置文件,它将具有应用程序ID和更新路径两个变量,当我将在api中传递应用程序ID时,它将返回该应用程序ID的更新路径。 我将如何实现配置文件的制作。

问候

rahul

3 个答案:

答案 0 :(得分:3)

您可以为项目创建一个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配置模式的另一个示例

ħ++号码://www.ibm.com/developerworks/library/os-php-config/index.html

答案 1 :(得分:1)

<?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";
?>

答案 2 :(得分:0)

我是通过制作一个数组

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

谢谢

的Rahul