Home > php教程 > php手册 > body text

ZF缓存类前端File配合XML的使用

WBOY
Release: 2016-06-06 19:33:13
Original
1114 people have browsed it

学习练习 Zend Framework ?xml version="1.0" encoding="UTF-8"?ConfigMysqlhost127.0.0.1/hostuserroot/userpassword111/passworddbnametest/dbname/Mysql/Config ?phprequire_once("Zend/Loader.php");//载入缓存类与Config类的子类XMLZend_Loader::loadCla

学习练习 Zend Framework
<?xml version="1.0" encoding="UTF-8"?>
<Config>
	<Mysql>
		<host>127.0.0.1</host>
		<user>root</user>
		<password>111</password>
		<dbname>test</dbname>
	</Mysql>
</Config>
Copy after login
<?php
require_once("Zend/Loader.php");
//载入缓存类与Config类的子类XML
Zend_Loader::loadClass("Zend_Cache");
Zend_Loader::loadClass("Zend_Config_Xml");
//实例化XML类(XML文件名,调用的节名)
$XML = new Zend_Config_Xml('config.xml','Mysql');
//前端配置:指定主文件名(PHP文件名),开启序列化(必须)
$Foptions = array('master_file' => 'Zend_Cache_File.php','automatic_serialization' => true);
//开启缓存(前端,后端,前端配置)
$Cache = Zend_Cache::factory('File','File',$Foptions);
//讲实例化的XML对象资源保存到缓存,并命名
$Cache -> save($XML,'config');
//载入缓存
$Result = $Cache -> load('config');
//----------调用XML--------------
echo "主机名是:" . $Result ->host . "<br>";
echo "用户名是:" . $Result ->user . "<br>";
echo "密码是:" . $Result ->password . "<br>";
echo "库名是:" . $Result ->dbname . "<br>";
?>
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!