自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

為你詳細(xì)講解PHP重定向代碼的具體實(shí)現(xiàn)功能

開發(fā) 后端
我們?yōu)榇蠹曳钌系氖荘HP重定向代碼,希望大家能夠收藏。作為以后編寫代碼時(shí)的參考和學(xué)習(xí)對(duì)象。

PHP語言是一個(gè)比較常用的功能強(qiáng)大的計(jì)算機(jī)語言。我們這次為大家編寫的這個(gè)PHP重定向代碼的功能很完善,可以很好地定制轉(zhuǎn)跳。#t#

PHP重定向代碼:

  1. < ?php
  2. /**
  3. * 重定向?yàn)g覽器到指定的 URL
  4. *
  5. * @param string $url 要重定向的 url
  6. * @param int $delay 等待多少秒以后跳轉(zhuǎn)
  7. * @param bool $js 指示是否返回用于跳轉(zhuǎn)的 JavaScript 代碼
  8. * @param bool $jsWrapped 指示返回
     JavaScript 代碼時(shí)是否使用
    < script> 標(biāo)簽進(jìn)行包裝
  9. * @param bool $return 指示是否返回生成的 JavaScript 代碼
  10. */
  11. function redirect($url, $delay = 0,
    $
    js = false, $jsWrapped = true, $return = false)
  12. {
  13. $delay = (int)$delay;
  14. if (!$js) {
  15. if (headers_sent() || $delay > 0) {
  16. echo < < < EOT
  17. < html>
  18. < head>
  19. < meta http-equiv="refresh"
    content="{$delay};URL={$url}" />
  20. < /head>
  21. < /html>
  22. EOT;
  23. exit;
  24. } else {
  25. header("Location: {$url}");
  26. exit;
  27. }
  28. }
  29. $out = '';
  30. if ($jsWrapped) {
  31. $out .= '< script language="
    JavaScript" type="text/javascript">'
    ;
  32. }
  33. $url = rawurlencode($url);
  34. if ($delay > 0) {
  35. $out .= "window.setTimeOut(function
     () { document.location='{$url}'; }, {$delay});"
    ;
  36. } else {
  37. $out .= "document.location='{$url}';";
  38. }
  39. if ($jsWrapped) {
  40. $out .= '< /script>';
  41. }
  42. if ($return) {
  43. return $out;
  44. }
  45. echo $out;
  46. exit;
  47. }
  48. ?>

希望通過上見介紹的這段PHP重定向代碼示例,大家能學(xué)到更多的知識(shí)。

責(zé)任編輯:曹凱 來源: 網(wǎng)易博客
相關(guān)推薦

2009-11-23 18:39:17

PHP重定向

2009-12-01 11:04:10

PHP重定向網(wǎng)頁

2009-11-24 15:43:17

PHP給圖片加水印

2010-03-09 16:11:59

Linux重定向

2010-05-04 14:42:33

Unix操作系統(tǒng)

2009-12-25 16:21:41

shell命令

2009-11-23 13:00:40

PHP獲取QQ郵箱好友

2009-12-02 19:08:19

PHP跳轉(zhuǎn)代碼

2009-11-30 15:10:46

PHP substr函

2009-11-23 17:56:44

PHP緩存機(jī)制

2010-12-14 15:07:15

ICMP路由重定向

2009-12-02 20:09:45

PHP頁面跳轉(zhuǎn)函數(shù)

2011-06-15 14:43:43

301重定向

2011-07-13 08:58:51

ASP.NET

2009-12-11 14:39:41

PHP函數(shù)mysql_

2009-11-25 10:31:35

PHP數(shù)組實(shí)現(xiàn)單鏈表

2011-07-07 14:14:41

PHP模版

2009-11-23 14:17:50

PHP 5.3閉包語法

2009-11-26 13:52:07

PHP字符串替換函數(shù)s

2009-12-22 10:34:18

靜態(tài)路由協(xié)議
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)