开发者

php \r and \n same thing?

Why have 2 functions that does the same thing? They both add a linebreak.

Any diffrence betw开发者_StackOverfloween them?


This has nothing to do with PHP, and is a consequence of history :

  • UNIX / Linux use \n for linebreaks
  • Mac (before OSX) used \r
  • And windows uses a combinaison of both

PHP has just kept that behavior -- so it can work with those different OSes and their files.


Also, note :

  • Those are not functions : they are (special) characters
  • They are not exactly the same thing :
    • \r is Carriage return
    • \n is Newline
  • and, btw, those are another consequence of history : look at their names, and think about typewriters ;-)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜