开发者

PHP New line character Windows vs. Macintosh

For a user input I do this: $var=str_replace(array('\r','\n'),'',$var);

Works well on Windows, removing any new lines. However, on the Mac (+Firefox) it somehow replaces the new lines with a \ 开发者_StackOverflow中文版character.

Any clues as to why that happens?


I'm surprised it works on Windows.

Usually, for PHP to interpret control characters, they need to be in double-quoted strings, eg

array("\r", "\n")


set the value auto_detect_line_endings to on in php.ini file or ini_set("auto_detect_line_endings", true);

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜