php download.php实现代码 跳转到下载文件(response.redirect)

yipeiwu_com6年前PHP代码库
跳转核心代码实现。
复制代码 代码如下:

if (isset($link))
                {
                    Header("HTTP/1.1 303 See Other");
                    Header("Location: $link");
                    exit;
                }



下面是国外的一篇文章说明。
Hey Chris:
On Wed, Jan 26, 2005 at 12:28:19PM -0500, csnyder wrote:
>
> <?php
> // process form
> ...
> // redirect to results page
> header( 'HTTP/1.1 303 See Other' );
> header( 'Location: result.html' );
> exit( 'Form submitted, <a href="result.html">continue</a>.' );
> ?>
Good point. But some feedback here. The optimail syntax is:
<?php
// process form
// ...
// redirect to results page
header('Status: 303 See Other' );
header('Location: //www.jb51.net/result.html');
?>
Here's why...
Using "Status:" in the header is better because the resulting headers from
Apache are more correct:
HTTP/1.1 303 See Other
instead of
HTTP/1.1 303
Additionally, one doesn't really know which version of HTTP is being used,
so why potentially cause problems by trying to guess.
The specs say location headers must have a complete URI in them, not just
the path.
Lastly, you don't want any output after the location header.
Later,
--Dan

相关文章

php提交post数组参数实例分析

本文实例分析了php提交post数组参数的用法。分享给大家供大家参考,具体如下: 首先php中要想从页面传送数组到服务端a,要在页面上多个空间同名,而且对于名称有要求,那就是 name=...

php 数组的一个悲剧?

复制代码 代码如下: $a=1; $b=2; $t = array( array('a', 'string', $field['a']), // 名称 if($a==$b){array(...

php显示时间常用方法小结

本文实例讲述了php显示时间常用方法。分享给大家供大家参考。具体分析如下: 一、PHP函数Date()获取当前时间 代码: 复制代码 代码如下:<?php echo $sh...

PHP中多维数组的foreach遍历示例

复制代码 代码如下: <?php //声明一个三维数组 $info=array( "user"=>array( array(1,"zhangsan",20,"nan"), a...

解析php dirname()与__FILE__常量的应用

__FILE__表示当前所在文件的绝对路径包括文件名,dirname(__FILE__)表示当前文件的绝对路径,basename(__FILE__)表示当前文件的文件名称,dirname...