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