saiyen2002 Posted February 6, 2010 Share Posted February 6, 2010 I am relatively new php programmer, and seem to be stuck on something really simple. As I understant it, \t gives you a tab and \n give you a new line. However this does not seem to be the case. Can some one please help me, i am really stressing over this. I am using the following on Fedora linux PHP 5.3.1 Apache/2.2.14 contents of file index.php <?php echo "hello \t world \n"; echo "hello \t universe \n"; ?> the out put of this code is hello world hello universe everything is on one line. Can somebody please help see the light! Quote Link to comment https://forums.phpfreaks.com/topic/191112-escape-character-newline-n-tab-t-not-working/ Share on other sites More sharing options...
premiso Posted February 6, 2010 Share Posted February 6, 2010 If you view the source you will see the proper indentation / new lines. In order for the browser to see it you will need to put inside of a <pre> tag: <?php echo "</pre>hello \t world \n"; echo "hello \t universe \n</pre>"; ?> Browsers tend to hide those due to the fact that html can have a ton of tabs and new lines in it that are not meant to be displayed. Quote Link to comment https://forums.phpfreaks.com/topic/191112-escape-character-newline-n-tab-t-not-working/#findComment-1007717 Share on other sites More sharing options...
taquitosensei Posted February 6, 2010 Share Posted February 6, 2010 that's because in html you should <br> and for tab just use 5 spaces Quote Link to comment https://forums.phpfreaks.com/topic/191112-escape-character-newline-n-tab-t-not-working/#findComment-1007719 Share on other sites More sharing options...
saiyen2002 Posted February 6, 2010 Author Share Posted February 6, 2010 thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/191112-escape-character-newline-n-tab-t-not-working/#findComment-1007853 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.