如何解决PHP中的隐形空间问题? [英] How to fix the invisible space problem in PHP?
问题描述
结果,session_start
和setcookie
之类的功能无法成功运行,报告:
As a result,functions like session_start
and setcookie
can't run successfully,reporting:
无法修改标题信息- 标头已经由
Cannot modify header information - headers already sent by
但是目标文件是这样的:
But the target file is like this:
1 <?php
2 session_start();
如何解决?
基础
我发现了问题,将utf-8格式的文件上传到服务器后变成了utf-8 + BOM,因此我通过将其再次保存为utf-8暂时解决了该问题.
I've found the problem,the utf-8 formated files become utf-8+BOM after uploading to the server,so I've temporarily solved the problem by saving it as utf-8 again.
但是,还有很多其他文件存在相同的问题,我该如何批量解决该问题?
BUT,there are lots of other files with the same problem,how can I batch solve the issue?
推荐答案
闻起来像BOM表问题,因为一些编辑器没有显示出来.尝试使用Notepad ++,Emacs或任何其他显示该文件的编辑器打开文件.如果在<之前有一些奇怪的字符,那么您就是罪魁祸首.
Smells like a BOM problem as some editors don't show it. Try opening your file with Notepad++, Emacs or any other editor which show it. If you have some weird character before the <, you got the culprit.
这篇关于如何解决PHP中的隐形空间问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!