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函数(简单整理)

sys_getloadavg() 这个函数返回当前系统的负载均值信息(当然 Windows 下不适用),详细文档可以翻阅 PHP 的相关文档。文档中有段示例代码,基本上也就能看出它的用途...

PHP设置进度条的方法

本文实例讲述了PHP设置进度条的方法。分享给大家供大家参考。具体如下: <html> <head> <style type="text/css">...

PHP 远程文件管理,可以给表格排序,遍历目录,时间排序

PHP 远程文件管理,可以给表格排序,遍历目录,时间排序

复制代码 代码如下: <?php $rootdir="./"; $spacenum=0; $filenum=0; $allfilesize=0; echo "<h1>文...

php字符串截取中文截取2,单字节截取模式

//中文截取2,单字节截取模式 function cn_substr($str,$slen,$startdd=0){     $re...

详谈PHP面向对象中常用的关键字和魔术方法

PHP面向对象中常用的关键字    final 1.final不能修饰成员属性(类中常量不是用这个关键字) 2.final只能修饰类和方法 作用: 使用fi...