php页面三种跳转.docxphp 页面三种跳转
方法一:使用
PHP
自带函数
Header("Location:
网址
") 中重定向 的比较:
例 1:
"../"
header("location:../");
两者区别 :
asp 的 redirect 函数可以在向客户发送头文件后起作用 .
如
<html><head></head><body>
<% "../"%>
</body></html>
查是 php 中下例代码会报错 :
<html><head></head><body>
<?
header("location:../");
?>
</body></html>
只能这样 :
<?
header("location:../");
?>
<html><head></head><body>...</bod
y></html>
即 header 函数之前不能向客户发送任何数据 . 例 2:
asp 中
<html><head></head><body>
<%
"../"
"../"
%>
</body></html>
结果是重定向 文件 .
php 呢?
<?
header("location:../");
header("location:../");
?>
<html><head></head><body></body
></html>
我们发现它重定向 .
原来在 asp 中执行 redirect 后不会再执行后面的代码 .
而 php 在执行 header 后 ,继续执行下面的代码 .
在这方面上 php 中的 header 重定向不如 asp 中的重定向 .
有时我们要重定向后 ,不能执行后面的代码 :
一般地我们用
if
php页面三种跳转 来自淘豆网m.daumloan.com转载请标明出处.