错误“;类';Zend_Config_Writer_Xml';未找到”;当将Zend-libary集成到Co


Error "Class 'Zend_Config_Writer_Xml' not found" when integrate Zend libary into CodeIgniter?

我复制了一些Zend库,并将它们粘贴到CodeIgniter中的库文件夹中。我试着使用这个代码,没关系:

$this->zend->load('zend/json');
$data = array(
    'name' => 'Killer Whale',
    'email' => 'namnguyen2091@gmail.com',
    'website' => 'baogiadientu.com'
);
// load and encode data
$json = new Zend_Json();
$encode = $json->encode($data);
echo $encode;
//decode with static function
echo '<pre>';
print_r(Zend_Json::decode($encode));
echo '</pre>';

但当我像下面这样编码时,它不起作用,我会得到一个错误:致命错误:在第83行的D:''Programs''examplep''htdocs''baogiadientu''application''controllers''product.php中找不到类"Zend_Config_Writer_Xml"

$this->zend->load('zend/config');
// create the config object
$config = new Zend_Config(array(), true);
$config->production = array();
$config->production->webhost = 'baogiadientu.com';
$config->production->database = array();
$config->production->database->params = array();
$config->production->database->params->host = 'localhost';
$config->production->database->params->username = 'root';
$config->production->database->params->password = '123456';
$config->production->database->params->dbname = 'baogiadientu';
$writer = new Zend_Config_Writer_Xml(); // **here**
echo $writer->toString($config);

我关注这篇文章http://framework.zend.com/manual/2.0/en/modules/zend.config.writer.html.请帮帮我!

您试图在那里做两件事:(1)加载并实例化Zend-Config对象;(2)对Zend_Config_Writer_Xml执行同样的操作-所有这些都不包括所需的文件。

您可能只需要在确保它们位于include_path 内之后要求("Zend/Config.php")和要求("Zend/Config/Writer/Xml.php")

您使用的是带有ZF2文档的ZF1库

请在他们的网站上查看正确的文档:

http://framework.zend.com/manual/1.12/en/zend.config.writer.introduction.html

相关文章: