PHP的头文件位置立即? [英] php header Location immediately?
本文介绍了PHP的头文件位置立即?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么Location标题不会立即重定向页面?
它总是在重定向之前执行整个过程?
我会举一些例子:
头( '位置:http://www.php.net');
$ f = fopen('demo.txt','w +');
fwrite($ f,'Test');
fclose($ f);
在重定向到 http:// www之前,它总是生成TXT文件。 php.net
。
解决方案
好的, header()
只是将某个标题发送给浏览器。 PHP在这之后仍然继续运行脚本。如果您不想停止运行脚本,只需使用 die;
或 exit;
- 它将停止处理脚本更进一步。
Why the Location header does not redirect the page immediately? It always performs the entire process before redirecting?
I will give some example:
header('Location:http://www.php.net');
$f = fopen('demo.txt','w+');
fwrite($f,'Test');
fclose($f);
It always generates the TXT file before redirecting to http://www.php.net
.
解决方案
Well, header()
just sends certain header to browser. PHP still continues running the script after that. If you don't want to stop running the script, just use die;
or exit;
- it will stop processing the script further.
这篇关于PHP的头文件位置立即?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文