The redirect method of TP frame is how to realize jump? A look at the source, completely incomprehensible AH

Source: Internet
Author: User
protected function Redirect ($url, $params =array (), $delay =0, $msg = ") {
$url = U ($url, $params);
Redirect ($url, $delay, $msg);
}



First live a URL, and then recursively pass in the third fourth parameter:


How does its jump come true???


Reply to discussion (solution)

Then you go and look at the definition of the redirect function.

The redirect in the function body is called a function:

See the framework's built-in functions.php file
redirect
Description
void Redirect ($url, $time =0, $msg = ")
URL redirection
Source:

    function Redirect ($url, $time =0, $msg = ") {        //multiline URL address support        $url = str_replace (Array (" \ n "," \ R "),", $url);        if (empty ($msg))            $msg = "The system will automatically jump {$time} seconds to {$url}! ";        if (!headers_sent ()) {            //redirect            if (0 = = = $time) {                header (' Location: ' $url);            } else {                header ("R efresh:{$time};url={$url} ");                Echo ($msg);            }            Exit ();        } else {            $str = "
 
   ";            if ($time! = 0)                $str. = $msg;            Exit ($STR);        }    }

URL redirection function Redirect ($url, $time =0, $msg = ") {    //multiline URL address support    $url = str_replace (" \ n "," \ R "),", $url) ;    if (empty ($msg))        $msg = "The system will automatically jump {$time} seconds to {$url}! ";    if (!headers_sent ()) {//If the header does not emit        //redirect if        (0 = = = $time) {            header (' Location: '. $url);//If no delay time is specified, send a Jump Header        } else {            header ("refresh:{$time};url={$url}");//If the delay time is set, a delay-refreshed header            Echo ($msg) is issued;        Exit ();    } else {//otherwise send meta tag, meaning ditto        $str = "
 
   ";        if ($time! = 0)            $str. = $msg;        Exit ($STR);}    }
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.