Sosa
Sosa

Reputation: 143

php \r and \n same thing?

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

Any diffrence between them?

Upvotes: 14

Views: 36530

Answers (1)

Pascal MARTIN
Pascal MARTIN

Reputation: 400932

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 :
  • and, btw, those are another consequence of history : look at their names, and think about typewriters ;-)

Upvotes: 34

Related Questions