ThePsion5 Posted May 30, 2006 Share Posted May 30, 2006 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 More sharing options...
aspnetguy Posted May 30, 2006 Share Posted May 30, 2006 try using \n for returns and \t for tabs $Output = "<ul>\n\t<li></li>\n\t<li></li>\n</ul>"; should come out <ul> <li></li> <li></li></ul> Link to comment Share on other sites More sharing options...
scott100 Posted May 30, 2006 Share Posted May 30, 2006 I'm thinking you need both these for a line break?\r\nI can't fully remember Link to comment Share on other sites More sharing options...
aspnetguy Posted May 30, 2006 Share Posted May 30, 2006 I'm thinking you need both these for a line break?\r\nI can't fully remember <{POST_SNAPBACK}> Maybe...in ASP.Net I only need \n Link to comment Share on other sites More sharing options...
ThePsion5 Posted May 30, 2006 Author Share Posted May 30, 2006 I just tried that and it worked fine, although for some reason it didn't work when i used an echo statement...go figure. Whenever you put it into a variable, the '\n' character does the trick. Thanks! Link to comment Share on other sites More sharing options...
justsomeguy Posted May 30, 2006 Share Posted May 30, 2006 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 More sharing options...
Jack McKalling Posted June 3, 2006 Share Posted June 3, 2006 (edited) 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 June 3, 2006 by Dan The Prof Link to comment Share on other sites More sharing options...
justsomeguy Posted June 4, 2006 Share Posted June 4, 2006 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 More sharing options...
justsomeguy Posted June 4, 2006 Share Posted June 4, 2006 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now