数据库 - Model 前置说明
官方开源项目 抓取代理IP

介绍

返回值类型,是指在API接口中,输出返回值的数据结构,Restful组件支持jsonxml两种类型,默认使用json

若需要修改默认的数据类型,可以修改/restful/config.php文件中的type配置项即可。

也可以在调用时,通过\x\Restful::type('json')方法,临时修改。

\x\Restful::type()

依赖类:\x\Restful
方法名:type()

参数:

  • string $type

    • 功能:指定使用哪种数据格式
    • 值单位:字符串
    • 默认值json
    • 其它值:xml

返回值:\x\Restful对象本身

示例代码:

namespace app\http;
use x\controller\Http;

/**
 * @Controller(prefix="")
*/
class Index extends Http
{
    /**
     * @RequestMapping(route="/", method="get", title="主页")
    */
    public function index() {
        // 使用XML返回结构
        return \x\Restful::type('xml')->callback();
    }
}

SW-X

企业级 - 高性能 PHP 框架

最后更新:3年前 . 作者-小黄牛

本篇目录