PHP header()不起作用 [英] PHP header() does not work

查看:164
本文介绍了PHP header()不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道为什么我的header()不重定向吗?

Does somebody know why my header() does not redirect?

我的脚本的最后一部分是:

The last part of my script is:

  header("location: test.php");
  die('died');

它写道:

died.

:((((

它应该在死之前必须重定向,但不是.

It should has to redirect before it dies, but it does not.

你有什么主意吗?

推荐答案

可能是要在您向浏览器输出一些文本/HTML之后调用header() -不.即使在调用之前发送了一个输出空间,您的header()调用也将被忽略.

It's probably that you're calling header() after you are outputting some text/HTML to the browser, which is a no-no. Your header() call will be ignored if even so much as a single space of output has been sent before the call.

换句话说,您的header()代码必须在脚本的开头,然后向用户显示任何内容.如果仍然无法使用,请确保您在php标记之外没有任何空格或其他空白.

In other words, your header() code needs to be at the start of your script, before you display anything to the user. If that still isn't working, make sure you don't have any spaces or other whitespace by mistake outside of your php tags.

这篇关于PHP header()不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆