CraigDee Posted December 10, 2010 Share Posted December 10, 2010 Hey Guys, First Post! Yay I have a problemo, I feel really stupid about having to ask this question. But basically I can't get a new line when I echo output in a script I am writing for my website. Here is the code: echo $newsentry; echo '_______ Read More..'; I tried '\n' I tried using " (double quotes) I have used ' (single quotes) I have positioned the Line Feed '\n' at the begining of an output, and at the end. Neither made any difference. I tried using carriage return '\r' too. Nothing. I haven't coded in PHP for a while, well nothing basic (I know that sounds rediculas but it has been mostly Apps etc, Client Scripts blah blah blah, but I haven't had to echo with a new line for a few years. Probably the last website which I wrote with my friend. So I checked the PHP manual, and I am clearly missing something when I am reading it, I understood it to mean (which as you can see from my code, is what I am currently doing), that you could just somehow type: echo "some string and it carries on to the second line"; However as I first thought, this makes no difference. Could this be a configuration on the Box that hosts this Site?? Sorry for sounding so stupid guys, I appreciate your help. -Craig Quote Link to comment https://forums.phpfreaks.com/topic/221255-line-feed-carrige-return-configuration-problem/ Share on other sites More sharing options...
harristweed Posted December 10, 2010 Share Posted December 10, 2010 echo $newsentry; echo '_______<br />Read More..'; ? Quote Link to comment https://forums.phpfreaks.com/topic/221255-line-feed-carrige-return-configuration-problem/#findComment-1145540 Share on other sites More sharing options...
CraigDee Posted December 10, 2010 Author Share Posted December 10, 2010 Guys I have worked it out. Although I still dont understand totally why \n doesn't make a new line. I need to use the HTML <br> tag. That does work. I guess because the page is embedded in HTML and is rendered within? So obviously any HTML tag used within a PHP output will render as though it was typed in source. I still don't understand though why \n still just doesn't work? I thought it would, as it is a correct syntax? Sorry about wasting your time guys. I will be posting here more often now anyway, so I can hopefully contribute back to the community anyway. Thanks, -Craig Quote Link to comment https://forums.phpfreaks.com/topic/221255-line-feed-carrige-return-configuration-problem/#findComment-1145542 Share on other sites More sharing options...
MMDE Posted December 10, 2010 Share Posted December 10, 2010 "\n" with magic quotes works as newline! (would be newline in the html source) You can just as well just do: ' '; but if you output in html, remember <br /> is line break Quote Link to comment https://forums.phpfreaks.com/topic/221255-line-feed-carrige-return-configuration-problem/#findComment-1145544 Share on other sites More sharing options...
CraigDee Posted December 10, 2010 Author Share Posted December 10, 2010 echo $newsentry; echo '_______<br />Read More..'; ? Yeah, sorry about that. I didnt read your post before I posted that last one. I was trying to save anyone having to respond, so sorry for the stupid question. I am used to running PHP scripts on Servers from Bash SSH or Terminal on the box etc. I still don't understand why \n doesn't work on its own though? Because there is no '\n' in HTML? I just figured PHP would render the '\n' as a HTML equivalent. Sorry again folks. -Craig *Edit - I forgot that <br> is break not new line. Not the best with HTML tags etc, get rusty from lack of use* Quote Link to comment https://forums.phpfreaks.com/topic/221255-line-feed-carrige-return-configuration-problem/#findComment-1145546 Share on other sites More sharing options...
CraigDee Posted December 10, 2010 Author Share Posted December 10, 2010 Guys here is a better question for you, I know this is not relevant to the Thread and that this is a PHP Forum, but HTML is obviously crucial to Webpage development with PHP. Is there like a 'Date Stamp' in HTML? So I could have code for example: <b>Todays Date Is $date</b> Is this easily done in HTML? What is the syntax for format etc? -Craig Quote Link to comment https://forums.phpfreaks.com/topic/221255-line-feed-carrige-return-configuration-problem/#findComment-1145554 Share on other sites More sharing options...
CraigDee Posted December 10, 2010 Author Share Posted December 10, 2010 Note- I am writing a simple script for my Site which effectivly acts like a 'Frame'. So each element of the page generated is pulled up from a remote/external/different file. So that when you wish to change, the links page, you only change the 'links' file, not every single page to update the Links area. When you want to change the menu, you only change the 'menu' file, not every single page on the Site just to update the Menu bar. Etc Etc. I have to display the current Date in a few of these sections. -Craig Quote Link to comment https://forums.phpfreaks.com/topic/221255-line-feed-carrige-return-configuration-problem/#findComment-1145561 Share on other sites More sharing options...
MMDE Posted December 10, 2010 Share Posted December 10, 2010 date function http://php.net/manual/en/function.date.php try: date('H:i:s - jS F Y') also in html 5, there will be a <time> tag. Quote Link to comment https://forums.phpfreaks.com/topic/221255-line-feed-carrige-return-configuration-problem/#findComment-1145564 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.