freebsdntu Posted December 23, 2007 Share Posted December 23, 2007 I have tried echo 'Hello World!\n', and the out put is like this: Hello World\n I don't know why it is like this. Quote Link to comment Share on other sites More sharing options...
juapo2 Posted December 23, 2007 Share Posted December 23, 2007 Hi, Im glad to help you, and you should take away your "\n" thats why it is appearing, just leave it: echo 'Hello World!' Im glad for helping you, if i had solved your problem, mark this thread as solved please Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted December 23, 2007 Share Posted December 23, 2007 the main reason is that you need double quotes to evaluate the caharacters. if you user "hello world \n" that will work because it will pringt a new line isntead of a "\" and a "n" gdlk Quote Link to comment Share on other sites More sharing options...
freebsdntu Posted December 23, 2007 Author Share Posted December 23, 2007 Hi, Im glad to help you, and you should take away your "\n" thats why it is appearing, just leave it: echo 'Hello World!' Im glad for helping you, if i had solved your problem, mark this thread as solved please Thank you for your help, but the problem is not solved, i have a series of echo statements, if I remove \n, then there won't be carriage returns. Quote Link to comment Share on other sites More sharing options...
freebsdntu Posted December 23, 2007 Author Share Posted December 23, 2007 the main reason is that you need double quotes to evaluate the caharacters. if you user "hello world \n" that will work because it will pringt a new line isntead of a "\" and a "n" gdlk This sounds rationale, but what if I do it like this : 'Hello Word"\n"', it still does not work. I guess I need to check with the escape characters. Since I would have "" symbols inside "" of echo Quote Link to comment Share on other sites More sharing options...
Zane Posted December 23, 2007 Share Posted December 23, 2007 This sounds rationale, but what if I do it like this : 'Hello Word"\n"', it still does not work. because you need to concat those 'Hello World' . "\n" Quote Link to comment Share on other sites More sharing options...
Kingy Posted December 23, 2007 Share Posted December 23, 2007 just put the whole line is double quotation marks.. echo "First Line\nSecond Line\nThird Line\n"; Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted December 23, 2007 Share Posted December 23, 2007 You can also get the newline depending on the system (UNIX: \n - Windows: \r\n - Mac: \r) from the constant PHP_EOL. <?php echo 'Something' . PHP_EOL; ?> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 23, 2007 Share Posted December 23, 2007 If you are expecting a line break to be displayed on the screen, you need to use the "<br>" tag. Browsers do not see the "\n", "\r" or "\r\n" line break characters as line breaks. Ken Quote Link to comment Share on other sites More sharing options...
freebsdntu Posted December 23, 2007 Author Share Posted December 23, 2007 Thank you for all your inputs, I think I have got it. Thank you very much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.