开发者

php \r and \n same thing?

开发者 https://www.devze.com 2022-12-15 21:14 出处:网络
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 :

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

精彩评论

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