當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Response::renderResponseLine方法代碼示例

本文整理匯總了PHP中Zend\Http\Response::renderResponseLine方法的典型用法代碼示例。如果您正苦於以下問題:PHP Response::renderResponseLine方法的具體用法?PHP Response::renderResponseLine怎麽用?PHP Response::renderResponseLine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Http\Response的用法示例。


在下文中一共展示了Response::renderResponseLine方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: redirect

 /**
  * Performs a HTTP redirection to specified URL with additional data.
  * It may generate redirected request using GET or POST HTTP method.
  * The function never returns.
  *
  * @param string $url URL to redirect to
  * @param array $params additional variable/value pairs to send
  * @param Response $response
  * @param string $method redirection method ('GET' or 'POST')
  */
 public static function redirect($url, $params = null, Response $response = null, $method = 'GET')
 {
     $url = self::absoluteUrl($url);
     $body = "";
     if (null === $response) {
         $response = new Response();
     }
     if ($method == 'POST') {
         $body = "<html><body onLoad=\"document.forms[0].submit();\">\n";
         $body .= "<form method=\"POST\" action=\"{$url}\">\n";
         if (is_array($params) && count($params) > 0) {
             foreach ($params as $key => $value) {
                 $body .= '<input type="hidden" name="' . $key . '" value="' . $value . "\">\n";
             }
         }
         $body .= "<input type=\"submit\" value=\"Continue OpenID transaction\">\n";
         $body .= "</form></body></html>\n";
     } else {
         if (is_array($params) && count($params) > 0) {
             if (strpos($url, '?') === false) {
                 $url .= '?' . self::paramsToQuery($params);
             } else {
                 $url .= '&' . self::paramsToQuery($params);
             }
         }
     }
     if (!empty($body)) {
         $response->setContent($body);
     } elseif (headers_sent()) {
         $response->setContent("<script language=\"JavaScript\"" . " type=\"text/javascript\">window.location='{$url}';" . "</script>");
     }
     $response->setStatusCode(302);
     $response->headers()->addHeaderLine('Location', $url);
     if (!headers_sent()) {
         header($response->renderResponseLine());
         foreach ($response->headers() as $header) {
             header($header->toString());
         }
     }
     echo $response->getBody();
     if (self::$exitOnRedirect) {
         exit;
     }
 }
開發者ID:rafalwrzeszcz,項目名稱:zf2,代碼行數:54,代碼來源:OpenId.php


注:本文中的Zend\Http\Response::renderResponseLine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。