background image

receive.php 的内容:
 
 
CODE:<?PHP
Echo “<pre>”;
Echo   $_GET["Name"];
Echo “</pre>”;
?> 
 
 
正确的方法是:
CODE:<?php
$Var=”hello php”;
$post= “receive.php?Name=”.urlencode($Var);
header(“location:$post”);
?> 
在接收页面你不需要使用 Urldecode(),变量会自动编码.
 
在 PHP 中用 header(“location:test.php”)进行跳转要注意以下几点:
 
 
1、location

和 :”号间不能有空格,否则会出错。

 
 
2、在用 header 前不能有任何的输出。
 
 
3、header 后的 PHP 代码还会被执行。
 
 
下面是和 asp 中重定向 response.redirect 的比较:
 
 
例 1: 
response.redirect “../test.asp” 
header(“location:../test.php”); 
两者区别: 
asp 的 redirect 函数可以在向客户发送头文件后起作用. 
如 
<html><head></head><body> 
<%response.redirect “../test.asp”%> 
</body></html> 
查是 php 中下例代码会报错: 
<html><head></head><body>