本文整理汇总了PHP中Arr::toxml方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::toxml方法的具体用法?PHP Arr::toxml怎么用?PHP Arr::toxml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::toxml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: after
public function after()
{
if ($this->format == 'xml') {
echo Arr::toxml($this->response, 'response');
} else {
echo json_encode($this->response, JSON_UNESCAPED_UNICODE);
}
}
示例2: ini_set
ini_set('unserialize_callback_func', 'spl_autoload_call');
error_reporting(E_ALL | E_STRICT);
//error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT);
//ini_set('display_errors', TRUE);
Kohana::init(array('base_url' => '/', 'index_file' => false));
Kohana::modules(array('database' => MODPATH . 'database', 'helper' => MODPATH . 'helper', 'cache' => MODPATH . 'cache', 'devtools' => MODPATH . 'devtools', 'logreader' => MODPATH . 'logreader', 'myadmin' => MODPATH . 'myadmin', 'media' => MODPATH . 'media'));
Kohana::$log->attach(new Log_File(APPPATH . 'logs'));
Route::set('list_apis', '<controller>(/<action>)(.<format>)', array('format' => '(json|xml)'))->defaults(array('controller' => 'api', 'action' => 'index'));
Route::set('catch_all', '<path>', array('path' => '.*'))->defaults(array('controller' => 'error', 'action' => '404'));
try {
echo Request::instance()->execute();
} catch (Exception $e) {
$response = array('errno' => $e->getCode(), 'errmsg' => $e->getMessage());
$uri = Request::instance()->uri();
$pathinfo = pathinfo($uri);
if (!empty($pathinfo['extension'])) {
$format = $pathinfo['extension'];
} else {
$format = 'json';
}
$response['url'] = $_SERVER['REQUEST_URI'];
//$response['data'] = file_get_contents('php://input');
if ($format == 'xml') {
header('Content-Type: application/xml; charset=utf-8');
echo Arr::toxml($response, 'response');
} else {
header('Content-Type: application/json; charset=utf-8');
echo json_encode($response, JSON_UNESCAPED_UNICODE);
}
Kohana::$log->add(Log::ERROR, json_encode($response, JSON_UNESCAPED_UNICODE));
}