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中fopen不能创建中文文件名文件的问题

之前网页的chartset用的是utf-8,文件也用utf-8,然后用fopen()创建一个中文文件名的文件时问题就出来了,文件名都是乱 码! 查看了很多文档试了不少方法都解决不了,本来...

PHP获取当前执行php文件名的代码

今天写表白墙时候的导航判断遇到的这个问题。我的解决思路是这样: 判断当前的php文件名来确定导航条的哪块高亮。 那php如何获取当前的url文件名呢? 我是这样处理的 :shock: 教...

PHP中检查isset()和!empty()函数的必要性

isset()函数是PHP中的内置函数,它检查变量是否已设置且不为NULL。此函数还检查声明的变量,数组或数组键是否具有空值,如果是,isset()返回false,它在所有其他可能的情况...

WordPress中用于创建以及获取侧边栏的PHP函数讲解

register_sidebar()(创建侧边栏) 建立一个侧边栏,用来放置小工具。这个函数使用的时候请放在一个函数里,挂载到 “widgets_init” 钩子。 用法 regis...

关于php 接口问题(php接口主要也就是运用curl,curl函数)

接口问题php调用接口最主要的就是使用curl抓取信息复制代码 代码如下:$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $url);&n...