当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::body方法代码示例

本文整理汇总了PHP中Slim\Http\Response::body方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::body方法的具体用法?PHP Response::body怎么用?PHP Response::body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slim\Http\Response的用法示例。


在下文中一共展示了Response::body方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: halt

 /**
  * Halt
  *
  * Stop the application and immediately send the response with a
  * specific status and body to the HTTP client. This may send any
  * type of response: info, success, redirect, client error, or server error.
  * If you need to render a template AND customize the response status,
  * use the application's `render()` method instead.
  *
  * @param  int      $status     The HTTP response status
  * @param  string   $message    The HTTP response body
  */
 public function halt($status, $message = '')
 {
     $this->cleanBuffer();
     $this->response->status($status);
     $this->response->body($message);
     $this->stop();
 }
开发者ID:sydorenkovd,项目名称:Rest-slim-news,代码行数:19,代码来源:Slim.php

示例2: toJson

 /**
  * @param int   $code
  * @param array $data
  */
 private function toJson($code, $data)
 {
     $this->response->header('Content-Type', 'application/json');
     $this->response->status($code);
     if (defined('JSON_PRETTY_PRINT')) {
         $this->response->body(json_encode($data, JSON_PRETTY_PRINT));
     } else {
         $this->response->body(json_encode($data));
     }
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:14,代码来源:BatchController.php

示例3: writeToJSON

 /**
  * convert array to json and parsing to body
  * @param $message
  * @param int $statusCode
  */
 protected function writeToJSON($message, $statusCode = 200)
 {
     $this->response->status($statusCode);
     $this->response['Content-Type'] = 'application/json';
     $this->response->body(json_encode($message));
 }
开发者ID:jeins,项目名称:basic-rest-api,代码行数:11,代码来源:Base.php


注:本文中的Slim\Http\Response::body方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。