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 解决扫描二维码下载跳转问题

php 解决扫描二维码下载跳转问题 首先我们指定一个url,比如 http://it.lovepet.vip 用这个地址生成二维码,二维码的生成方式有很多种,到网上搜搜就知道。 我们可...

PHP 正则表达式之正则处理函数小结(preg_match,preg_match_all,preg_replace,preg_split)

前面我们已经学习了正则表达式的基础语法,包括了定界符、原子、元字符和模式修正 符。实际上正则表达式想要起作用的话,就必须借用正则表达式处理函数。本节我们就来介绍一下PHP中基于perl的...

PHP 判断常量,变量和函数是否存在

复制代码 代码如下:if (defined('CONST_NAME')) {    //do something } 变量检测则是使用isset,注意变量未...

解决php使用异步调用获取数据时出现(错误c00ce56e导致此项操作无法完成)

【详细错误】:由于出现错误 c00ce56e 而导致此项操作无法完成 【造成原因】:未指定输出编码格式。 【解决办法】:句首加入header("content-type:text/htm...

php实现xml与json之间的相互转换功能实例

本文实例讲述了php实现xml与json之间的相互转换功能。分享给大家供大家参考,具体如下: 用php实现xml与json之间的相互转换: 相关函数请查看php手册。 一、参考xml如下...