From ba1496cd508ca003bff8ffbae5e1d055a652e5b0 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 28 Sep 2013 20:11:24 -0400 Subject: [PATCH] doc fix. --- framework/yii/web/Response.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/framework/yii/web/Response.php b/framework/yii/web/Response.php index e6505fd..f0d506b 100644 --- a/framework/yii/web/Response.php +++ b/framework/yii/web/Response.php @@ -559,7 +559,20 @@ class Response extends \yii\base\Response /** * Redirects the browser to the specified URL. * - * This method will send out a "Location" header to achieve the redirection. + * This method adds a "Location" header to the current response. Note that it does not send out + * the header until [[send()]] is called. In a controller action you may use this method as follows: + * + * ~~~ + * return Yii::$app->getResponse()->redirect($url); + * ~~~ + * + * In other places, if you want to send out the "Location" header immediately, you should use + * the following code: + * + * ~~~ + * Yii::$app->getResponse()->redirect($url)->send(); + * return; + * ~~~ * * In AJAX mode, this normally will not work as expected unless there are some * client-side JavaScript code handling the redirection. To help achieve this goal, @@ -578,12 +591,6 @@ class Response extends \yii\base\Response * }); * ~~~ * - * In a controller action you may use this method like this: - * - * ~~~ - * return Yii::$app->getResponse()->redirect($url); - * ~~~ - * * @param string|array $url the URL to be redirected to. This can be in one of the following formats: * * - a string representing a URL (e.g. "http://example.com")