thinkphp source learning redirect function URL redirection

Source: Internet
Author: User

Tag:php   think    source learning    

/** * url redirect  *  @param  string  $url   redirected URL  *  @param  integer   $time   Redirection wait time (seconds)  *  @param  string  $msg   REDIRECT Information  *  @return   void */  $url = ' http://www.baidu.com ';  $time =3;function redirect ($url,  $time =0, $ Msg= ')  {//multi-line URL address support      $url         =  Str_replace ("\ n",  "\ r"),  ',  $url);//  $url string newline character \n  carriage return \ r Replace with empty//give hint        if  (Empty ($msg))          $msg      =  "The system will automatically jump to {$url}! after {$time} seconds ";//headers_sent - checks if or where headers have been sent     if  (Headers_sent ())  {//headers_sent is false// redirect   when not sent       if  (0 ===  $time)  { &nbsP;          header (' location:  '  .  $url);// Location Locator         } else {           header ("refresh:{$time};url={$url}");//refresh re-refresh              echo ($msg);        }         exit ();     } else {//headers_sent sent status  html scheduled Refresh          $str     =  "<meta  http-equiv= ' Refresh '  content= ' {$time}; url={$url} ' > ';        if  ($time  != 0)               $str  .=  $msg;         exit ($STR);     }}


This article is from the "11400485" blog, please be sure to keep this source http://11410485.blog.51cto.com/11400485/1833432

thinkphp source learning redirect function URL redirection

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.