php 标头已发送错误

发布于 2024-09-11 03:18:51 字数 410 浏览 1 评论 0原文

我有一个 php 文件,其中包含以下代码:

<?php header("Location: somepage.php"); ?>

在 php 开始或结束标记之前或之后绝对没有空格,并且我收到通常

Warning: Cannot modify header information - headers already sent by (output started at C:\ ... \test.php:1

当我收到此错误时,1 是问题的行号,但在此case 第一行没有任何额外的空格。我的页面上只有此代码,不包含任何其他文件。

我在 Windows XP 上使用 xampp。任何想法发生了什么或者我如何找出真正导致问题的原因。

谢谢

I have a single php file, with this code in it:

<?php header("Location: somepage.php"); ?>

Absolutely no spaces before or after the php opening or closing tags and I am getting the

Warning: Cannot modify header information - headers already sent by (output started at C:\ ... \test.php:1

Usually when I get this error, the 1 is the line number of the problem, but in this case line one doesn't have any extra whitespace. I only have this code on the page and I am not including any other files.

I'm using xampp on windows xp. Any ideas what's going on or how I can track down what's really causing the problem.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

平定天下 2024-09-18 03:18:51

文件中可能存在所谓的 BOM(字节顺序标记)。根据您使用的编辑器,您需要关闭添加 BOM...

Chances are that you have what's known as a BOM (Byte Order Mark) in the file. Depending on what editor you're using, you'll need to turn off adding the BOM...

水溶 2024-09-18 03:18:51

尝试使用记事本将您的内容复制/粘贴到另一个新文件

Try to copy / paste your content to another new file using Notepad

你曾走过我的故事 2024-09-18 03:18:51

尝试使用 WAMP,它不会显示此错误,请确保代码前后没有空格。为此,如果您使用的是记事本++或editplus,请转到格式并选择unix格式,一切应该可以正常工作。

或者

尝试将其放在页面顶部:

<? ob_start(); ?>

然后在页面底部放置此行代码:

<? ob_flush(); ?> 

Try using WAMP, it doesnt show this error, make sure you donot have spaces before or after the code. For that, if you are using notepad ++ or editplus, go to format and select unix formatting and things should work fine.

OR

try placing this at the top of your page:

<? ob_start(); ?>

then at the bottom of the page place this line of code:

<? ob_flush(); ?> 
近箐 2024-09-18 03:18:51

如果您确定不是 BOM 导致错误,请检查您的 httpd.conf 和任何 .htaccess 文件(如果前置有任何其他文件)。留意类似这样的内容:

<FilesMatch "\.(html?)$">
php_value auto_prepend_file /server/path/to/my/www_root/subdir/file.ext"
</FilesMatch>

同时检查您的 PHP.ini: http://de.php.net/manual/en/ini.core.php#ini.auto-prepend-file

If you are sure it is not a BOM causing the error, check your httpd.conf and any .htaccess files if the prepend any other files. Look out for something like this:

<FilesMatch "\.(html?)$">
php_value auto_prepend_file /server/path/to/my/www_root/subdir/file.ext"
</FilesMatch>

Also check your PHP.ini: http://de.php.net/manual/en/ini.core.php#ini.auto-prepend-file

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文