相关关键词
关于我们
最新文章
Zend Framework入门教程之Zend_Config组件用法详解
发布日期:2016-12-09 00:00:00
80
本文实例讲述了Zend Framework中Zend_Config组件用法。分享给大家供大家参考,具体如下:
1.从PHP数组中读取数据
使用Zend_Config_Ini(读取ini配置文件)
Zend_Config_Xml(读取XML配置文件)
案例:
<?php require_once("Zend/Loader.php"); Zend_Loader::loadClass('Zend_Config'); $array = array( 'webhost' => '127.0.0.1', 'database'=>array( 'db_host'=>'localhost', 'db_user'=>'root', 'db_pass'=>'123', 'db_name'=>'test' ) ); $config = new Zend_Config($array); echo "Web服务器地址为:"; echo $config->webhost; echo "<p>"; echo "数据库服务器名称为:"; echo $config->database->db_host; echo "<p>"; echo "数据库用户名为:"; echo $config->database->db_user; echo "<p>"; echo "数据库密码为:"; echo $config->database->db_pass; echo "<p>"; echo "数据库名称为:"; echo $config->database->db_name; echo "<p>";