换行符被插入到文件开头
我的代码可以在我的主生产服务器上生成 Google KML feed,运行良好。当我将其复制到辅助生产镜像时,文件开头有一个换行符。其他一切都很好。有人知道哪些配置选项可能会强制换行符成为正在创建的文件的第一个字符吗?
生成文件的代码:
header('Content-type: application/vnd.google-earth.kml+xml');
header('Content-Disposition: attachment; filename="My KML.kml"');
echo '<?xml version="1.0" encoding="UTF-8"?>\n' .
'<kml xmlns="http://earth.google.com/kml/2.2">\n' .
'(The rest of the KML code)';
I have code that generates a Google KML feed on my primary production server that works fine. When I copy it to the secondary production mirror, there's a newline at the beginning of the file. Everything else works fine. Would anyone happen to know which configuration options could possibly force a newline to be the first character of a file being created?
Code to generate the file:
header('Content-type: application/vnd.google-earth.kml+xml');
header('Content-Disposition: attachment; filename="My KML.kml"');
echo '<?xml version="1.0" encoding="UTF-8"?>\n' .
'<kml xmlns="http://earth.google.com/kml/2.2">\n' .
'(The rest of the KML code)';
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该文件很可能是从另一个文件中包含的,该文件底部有一个额外的回车符。找到带有额外回车符的文件,你就会找到罪魁祸首。
Most likely the file is being included from another file which has an extra carriage return at the bottom. Find the file with the extra carriage return and you will find the culprit.