【发布时间】:2013-12-16 17:09:01
【问题描述】:
我复制了一些 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\xampp\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。请帮帮我!
【问题讨论】:
标签: php codeigniter zend-framework