Example #1
0
<?php

require_once './response.php';
//模拟一个数据库数据;
$arr = array('id' => 1, 'name' => 'hanfeng', 'type' => array(4, 5, 6), 'diff' => array(2, 4, 5 => array('123', 'abc')));
//调用jsonCode方法;
//Response::jsonCode(200,'success',$arr);
//调用xmlCode方法;
//ob_clean(); //清除缓冲区,否则xml 前两行会空白,导致报错 2.或者去掉php 的结束标签;
//Response::xmlCode(200,'success',$arr);
//调用toApi方法;
Response::toApi(200, 'success', $arr);