Jump to content

Line Feed, Carrige Return? Configuration Problem?


CraigDee

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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*

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.