Jump to content

Return Characters


ThePsion5

Recommended Posts

Hi,I had looked around before but couldn't seem to figure this out - what is the character equivalent to an HTML return...most of the php i wrote dumps HTML code into a variable and then outputs it at the end of the document, but one disadvantage of doing this is that my HTML code has no returns whatsoever, making it completely unreadable. Aside from doing something like this

$Output .= "";

how do I go about adding returns to HTML outputted by PHP? Thanks in advance!-Sean

Link to comment
Share on other sites

It will work in any string or echo statement as long as it is surrounded by double-quotes, if the string is surrounded by single-quotes, it will print out the characters "\n". With regard to \r and \n, this is pretty much the way things are:UNIX: \nMac: \rWindows: \r\nGenerally, you can stick to UNIX-style line endings, with a few exceptions like email headers, which must be separated with \r\n.

Link to comment
Share on other sites

The actual difference between \r\n and just \n is that \r\n works in every editor, even Wordpad, but \n only in notepad :)Carriage return and newline..Both together act as a line break in the source code. Both together does not mean there are two line breaks though! Wordpad doesn't recognise the \n character I presume, but is does for \r\n.Test it by viewin the source of a certain webpage that was build by uring \n and \r\n for linebreaks, in both notepad and wordpad. You'd see wordpad won't break the line at \n where notepad will, but both will at \r\n.It would also count for every other editor like wordpad that can apply special style to the text.

Edited by Dan The Prof
Link to comment
Share on other sites

With any decent text editor (such as ConTEXT), you can specify if you want the editor to use UNIX-style line endings, Windows-style, and sometimes Mac-style.The actual difference is that the different OS's were using different line endings, and various editors today try to account for that.Code only has CRLF as a line ending if you created it under DOS or Windows. If you transfer a file from a Linux server after creating it on there, you will see it has only LF for line endings.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...