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

yipeiwu_com4年前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

相关文章

PHP7数组的底层实现示例

PHP7数组的底层实现示例

PHP 数组具有的特性 PHP 的数组是一种非常强大灵活的数据类型,在讲它的底层实现之前,先看一下 PHP 的数组都具有哪些特性。 可以使用数字或字符串作为数组健值 $arr =...

php绘图之加载外部图片的方法

本文实例讲述了php绘图之加载外部图片的方法。分享给大家供大家参考。具体实现方法如下: 在实际应用中,就是常见的水印功能。 复制代码 代码如下:<?php //1、创建画布...

php 如何获取数组第一个值

reset (PHP 3, PHP 4, PHP 5)reset -- 将数组的内部指针指向第一个单元 说明mixed reset ( array &array )reset() 将 a...

php中cookie实现二级域名可访问操作的方法

本文实例讲述了php中cookie实现二级域名可访问操作的方法。分享给大家供大家参考。具体方法如下: cookie在一些应用中很常用,假设我有一个多级域名要求可以同时访问主域名绑定的co...

php断点续传之文件分割合并详解

php实现断点续传,就需要把大文件分割成多个小文件,然后单个上传。传完后在合并。 │ merge.php –合并文件脚本 │ merge.zip –合并后文件 │ socket.zi...