What is this string: Ôªø and how do I avoid it?

不羁岁月 提交于 2021-01-27 12:26:28

问题


Somehow I managed to stick Ôªø at the top of a PHP script. What is that horrifying group of characters, how could I have entered it, and how can I expose and/or avoid it in the future?

Anecdotally, it was lurking at the very top of a PHP script, before <?php. The script needed to send a Content-type header. Because Ôªø pushed the header off the top of the file, the server kept sending its own header, and 2 hours of hilarity ensued. I couldn't even see the string in nano or bash. But I redirected a diff and there it was.


回答1:


That's UTF-8 byte order mark (look for EF BB BF). This is a standard thing and shouldn't cause you problems, but if it does then make sure your source code editor doesn't prepend the file with BOM when saving it.




回答2:


That's most certainly an encoding error. Most likely, you're saving your script as one format, but uploading it or declaring it as another. I can't offer any further advice because I don't know much about encoding errors or how to fix them. Good luck squashing the bug.



来源:https://stackoverflow.com/questions/1837626/what-is-this-string-%c3%94%c2%aa%c3%b8-and-how-do-i-avoid-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!