本文整理汇总了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;
}
}