Asf_Config_Php


Introduction

Asf_Config_Php 读取php配置文件

如果设置ini配置项 asf.cache_config_enable=1, 配置内容会常驻内存

在开启命名空间情况下(asf.use_namespace=1)类名为 Asf\Config\Php

Class synopsis

<?php
final class Asf_Config_Php extends Asf_Config_AbstractConfig
{
    public function __construct(string $file_path)
}

Examples

conf.php 文件内容

return array(
    'host' => '127.0.0.1',
    'port' => 6379,
    'password' => '123456',
    'timeout' => 1,
    'persistent' => 0,
    'other' => array(
        'pass' => '654321'
    )
);

Example #1 获取配置

<?php
$config = new Asf_Config_Php("/path/conf.php");

var_dump($config->get('host1', 'none'));
var_dump($config->get('host'));
var_dump($config->get('other')->pass);
var_dump($config->host);
print_r($config->other->toArray());