亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

PHP封裝的一個(gè)支持HTML、JS、PHP重定向的多功能跳轉(zhuǎn)函數(shù)

 更新時(shí)間:2014年06月19日 10:47:08   投稿:junjie  
這篇文章主要介紹了PHP封裝的一個(gè)支持HTML、JS、PHP重定向的多功能跳轉(zhuǎn)函數(shù),需要的朋友可以參考下

PHP 跳轉(zhuǎn),即重定向?yàn)g覽器到指定的 URL,是一個(gè)很常見的功能。這種功能也有一些細(xì)節(jié)性的要求,比如等待多少秒以后跳轉(zhuǎn),用不用JavaScript實(shí)現(xiàn)跳轉(zhuǎn),等等。下面的跳轉(zhuǎn)方法考慮到很多,并參數(shù)化,可以用到具體的項(xiàng)目當(dāng)中。

<?php   
/**   
 * 重定向?yàn)g覽器到指定的 URL   
 *   
 * @param string $url 要重定向的 url   
 * @param int $delay 等待多少秒以后跳轉(zhuǎn)   
 * @param bool $js 指示是否返回用于跳轉(zhuǎn)的 JavaScript 代碼   
 * @param bool $jsWrapped 指示返回 JavaScript 代碼時(shí)是否使用 <mce:script type="text/javascript"><!-- 
 標(biāo)簽進(jìn)行包裝   
 * @param bool $return 指示是否返回生成的 JavaScript 代碼   
 */    
function redirect($url, $delay = 0, $js = false, $jsWrapped = true, $return = false)     
{     
  $delay = (int)$delay;     
  if (!$js) {     
    if (headers_sent() || $delay > 0) {     
      echo <<<EOT     
  <html>     
  <head>     
  <meta http-equiv="refresh" content="{$delay};URL={$url}" />     
  </head>     
  </html>     
EOT;     
      exit;     
    } else {     
      header("Location: {$url}");     
      exit;     
    }     
  }     
    
  $out = '';     
  if ($jsWrapped) {     
    $out .= '<script language="JavaScript" type="text/javascript">';     
  }     
  $url = rawurlencode($url);     
  if ($delay > 0) {     
    $out .= "window.setTimeOut(function () { document.location='{$url}'; }, {$delay});";     
  } else {     
    $out .= "document.location='{$url}';";     
  }     
  if ($jsWrapped) {     
    $out .= ' 
// --></mce:script>';     
  }     
    
  if ($return) {     
    return $out;     
  }     
    
  echo $out;     
  exit;     
}    
?>

相關(guān)文章

最新評論