php url重定向(页面跳转)的代码
发布时间:2016-01-08 编辑:jiaochengji.com
为大家介绍一个比较完善的url重定向、页面跳转的代码,有需要的朋友,可以参考下。
代码如下:
<?php /** * 重定向浏览器到指定的 URL * www.jbxue.com * @param string $url 要重定向的 url * @param int $delay 等待多少秒以后跳转 * @param bool $js 指示是否返回用于跳转的 JavaScript 代码 * @param bool $jsWrapped 指示返回 JavaScript 代码时是否使用 <mce:script type="text/javascript"><!-- 标签进行包装 * @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; } ?>
>>> 您可能感兴趣的文章:
PHP 页面跳转的多种方法总结
页面跳转代码(php、asp、js多版本)
PHP Header 页面跳转注意事项
php实现页面跳转的别样方法
php实现页面跳转的几种方法
header跳转和include包含问题实例分析
您可能感兴趣的文章:
php url重定向(页面跳转)的代码
php页面跳转函数 页面重定向
php如何实现页面跳转
PHP 页面跳转的多种方法总结
php页面跳转与定时跳转页面方法
有关php页面重定向的三种方法
PHP页面跳转的几种方式
PHP页面跳转代码的三种实现方式
PHP页面跳转的三种方法
php如何重定向页面跳转?
[关闭]