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一句话cmdshell新型 (非一句话木马)

php一句话cmdshell新型 (非一句话木马)

复制代码 代码如下:<?php /*一个新型的php一句话cmdshell(非一句话木马) //原理:php运行时如果遇见字符``(键盘上~符号的下档键)总会尝试着执行``里面包含...

PHP基于工厂模式实现的计算器实例

本文实例讲述了PHP基于工厂模式实现的计算器。分享给大家供大家参考。具体如下: abstract class Calculator { private $number1; pr...

PHP查询大量数据内存耗尽问题的解决方法

从数据库查询大量数据时会出现内容不够的提示: PHP Fatal error: Allowed memory size of 268 435 456 bytes exhausted 这个...

PHP的PDO操作简单示例

本文实例讲述了PHP的简单PDO操作。分享给大家供大家参考,具体如下: 网上关于PDO的资料很多。这里就不累赘了。 这里我将PDO所有操作封装到一个类里方便操作。 类代码如下: cl...

PHP入门教程之数组用法汇总(创建,删除,遍历,排序等)

本文实例总结了PHP数组用法。分享给大家供大家参考,具体如下: Demo1.php <?php //创建一个数组变量 $userNames = array('张...