php头函数在它不应该的时候会产生一个错误 [英] php header function produces an error when it shouldnt
问题描述
我正在使用PHP 4.3.11,当我执行一个头文件时,
警告:无法修改标题信息 - 已经发送的标题(输出开始于d:\folder\file.php:1 )在 d:\folder\file.php 在线 2
警告: / strong>无法修改标题信息 - d:\folder\file.php 在 上已发送的标题(输出开始于d:\folder\file.php:1) strong> 3
当前PHP版本:4.3.11
我用来产生这个错误的代码是
<?php
header(Cache-Control:no-cache,must-revalidate); // HTTP / 1.1
header(Expires:Sat,26 Jul 1997 05:00:00 GMT); //过去的日期
echo'当前PHP版本:'。 phpversion();
//例如打印'2.0'或者如果扩展未启用,则不做任何操作
echo phpversion('tidy');
?>
在php标签之前或之后没有空格和换行符,并且在5中有相同的代码。 x版本只返回php版本。
任何线索?
预先致谢
编辑:
已解决!:我用西欧编码打开了文件并删除了物料清单,它的工作。感谢您的帮助!
您是否有 UTF BOM 在文件开始处?
Im working with PHP 4.3.11 and when I execute a header always responds with an error like this
Warning: Cannot modify header information - headers already sent by (output started at d:\folder\file.php:1) in d:\folder\file.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at d:\folder\file.php:1) in d:\folder\file.php on line 3 Current PHP version: 4.3.11
the code I used to generate this error was
<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
echo 'Current PHP version: ' . phpversion();
// prints e.g. '2.0' or nothing if the extension isn't enabled
echo phpversion('tidy');
?>
It has no spaces nor newlines before or after the php tags, and the same code in a 5.x version returns just the php version as expected.
Any clue?
Thanks in advance
Edit: Solved!: I've opened the file with western european encoding and deleted the BOM and it worked. Thanks all for your help!
Do you have a UTF BOM at the start of the file?
这篇关于php头函数在它不应该的时候会产生一个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!