开发者

Weird Characters in PHP File

I have a weird issue where my PHP files have lost their line breaks and appear to have weird box/rectangle shaped characters in开发者_如何学运维 them. I have no clue how to fix them and they are interfering with my website.


What editor are you using? That is a symptom of trying to edit Unix format files in MS notepad (amongst other combinations).

Your files have most likely been converted by an FTP transaction of uploading them to the remote server (because the client correctly used TYPE A) and not converted back when you retrieved them (because it incorrectly used TYPE I).

Either get a better editor (like Notepad++ or EditPadPro) or force your FTP client into ASCII mode (TYPE A).

FYI, on *nix a line ending character is LF only (\n), on Windoze it is CRLF (\r\n) and on Mac it is CR only (\r).


By the way, this can still occasionally happen in Notepad++ if you use Notepad++'s FTP plugin and do not set the FTP plugin (nppftp) settings to ASCII. That is why I found this post.


You are likely seeing the difference between Windows and Unix line breaks.

Windows uses CR+LF whereas Unix-based systems simply use LF.

See also: http://en.wikipedia.org/wiki/Line_break_(computing)#Representations

PHP will parse both, so I doubt that is the reason your code isn't running. Of course, with no file posted, this is only a best guess (and a common issue).


Yes, as Brad said, you probably have the wrong line breaks. Assuming that you're on a *nix system, run dos2unix <filename>, and that will replace the Windows endline \r\n with the *nix endline character of \n.


You just enabled "Show Linebreaks" or "Show special characters" in your editors menu options. So now, rather than an invisible "\n" or "\r\n" you are seeing a representation of them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜