Carriage Return

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Carriage Return

Post by spacebiscuit »

What is the difference between:

'\r' and '\n'

I know that they are used as a carriage returm, is it possible to use them seperately or are they always used in conjunction with each other?

Thanks,

Rob.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Carriage Return

Post by requinix »

They're simply two different characters. \r is a carriage return, \n is a line feed.

Mostly for line endings: Unix uses \n, Windows uses \r\n, and Mac uses \r.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Carriage Return

Post by spacebiscuit »

Thanks for clearing that one up!

Rob.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Carriage Return

Post by AbraCadaver »

tasairis wrote:They're simply two different characters. \r is a carriage return, \n is a line feed.

Mostly for line endings: Unix uses \n, Windows uses \r\n, and Mac uses \r.
Does the newer OS X still use \r or the unixy \n or does it depend upon the program? I would assume that whatever the GUI apps use, vi or other such unixy program would still use \n.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply