send() public method

发送数据到客户端
public send ( ) : mixed
return mixed
Example #1
0
 /**
  * @covers think\Response::tramsform
  * @todo Implement testTramsform().
  */
 public function testTramsform()
 {
     Response::tramsform(function () {
         return "callbackreturndata";
     });
     $dataArr = [];
     $result = Response::send($dataArr, "", true);
     $this->assertEquals("callbackreturndata", $result);
     Response::tramsform(null);
 }
Example #2
0
File: Error.php Project: klsf/kldns
 /**
  * 输出异常信息
  * @param  \Exception $exception
  * @param  Array      $vars      异常信息
  * @return void
  */
 public static function output($exception, array $vars)
 {
     http_response_code($exception instanceof Exception ? $exception->getHttpStatus() : 500);
     $type = Config::get('default_return_type');
     if (IS_API && 'html' != $type) {
         // 异常信息输出监听
         APP_HOOK && Hook::listen('error_output', $data);
         // 输出异常内容
         Response::send($data, $type, Config::get('response_return'));
     } else {
         //ob_end_clean();
         extract($vars);
         include Config::get('exception_tmpl');
     }
 }
Example #3
0
 /**
  * 输出异常信息
  * @param  \Exception $exception 
  * @param  Array      $vars      异常信息
  * @return null
  */
 public static function output(\Exception $exception, array $vars)
 {
     if ($exception instanceof Exception) {
         http_response_code($exception->getHttpStatus());
     } else {
         http_response_code(500);
     }
     // header('Content-Type: application/json');
     // echo json_encode($vars);exit;
     $type = Config::get('default_return_type');
     if (IS_API && 'html' != $type) {
         // 异常信息输出监听
         APP_HOOK && Hook::listen('error_output', $data);
         // 输出异常内容
         Response::send($data, $type, Config::get('response_return'));
     } else {
         ob_end_clean();
         extract($vars);
         include Config::get('exception_tmpl');
     }
 }