# PHP: newline character doesn't work?

**URL:** https://forum.kirupa.com/t/php-newline-character-doesnt-work/116948
**Category:** Uncategorized
**Created:** [July 22, 2004, 6:53pm UTC](https://forum.kirupa.com/t/php-newline-character-doesnt-work/116948 "2004-07-22T18:53:12Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Kajinku](https://avatars.discourse-cdn.com/v4/letter/k/94ad74/32.png) [@Kajinku](https://forum.kirupa.com/u/Kajinku)
#### Post date: [July 22, 2004, 6:53pm UTC](https://forum.kirupa.com/t/php-newline-character-doesnt-work/116948/1 "2004-07-22T18:53:12Z")

</div>

Hello,

I have this:

```auto
while ($row = mysql_fetch_object($result)){
echo "$row->photo_filename
";
echo "$row->photo_caption
";
echo "$row->photo_security";
}

```

So I want the 3 fields displayed on 3 different lines. Except that the newline character doesn’t seem to work. Am I doing something wrong with the newline character?

Thanks in advance! 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 22, 2004, 7:59pm UTC](https://forum.kirupa.com/t/php-newline-character-doesnt-work/116948/2 "2004-07-22T19:59:02Z")

</div>

I would recommend using \<br /\> isntead of  
. I guess  
only works when using file editiing

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 22, 2004, 8:32pm UTC](https://forum.kirupa.com/t/php-newline-character-doesnt-work/116948/3 "2004-07-22T20:32:40Z")

</div>

Actually, it is working. If you right click and view source, you will see that they are on seperate lines. To make it actually appear like that though, you have to do what Hamza said and do \<br\> or I guess the proper way is \<br /\>

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 7:43am UTC](https://forum.kirupa.com/t/php-newline-character-doesnt-work/116948/4 "2004-07-23T07:43:15Z")

</div>

> [@Yeldarb](#):
>
> Actually, it is working. If you right click and view source, you will see that they are on seperate lines. To make it actually appear like that though, you have to do what Hamza said and do \<br\> or I guess the proper way is \<br /\>

You lost me there. I think the reason why they are on seperate lines when viewing the source is because I entered the code that way… pressing enter after each line. It’s just that when echo-ing this on a HTML page, it displays everything on one line.

Thank you both for the \<br\> tip. What is \<br /\>?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 7:54am UTC](https://forum.kirupa.com/t/php-newline-character-doesnt-work/116948/5 "2004-07-23T07:54:13Z")

</div>

BR is a hard return in HTML. The  
is a hard return in the source. Try it out - if you just leave out all the  
’s and look at your HTML source, you’ll see that it’s all on one line. PHP is printing the source code of your HTML file - therefore a  
will become a newline in the source code. A \<br/\> (XHTML strict version of \<br\>) in the source code of a HTML file will result in a newline on the HTML page, but a newline in the source code won’t.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 8:14am UTC](https://forum.kirupa.com/t/php-newline-character-doesnt-work/116948/6 "2004-07-23T08:14:25Z")

</div>

> [@Voetsjoeba](#):
>
> BR is a hard return in HTML. The  
> is a hard return in the source. Try it out - if you just leave out all the  
> 's and look at your HTML source, you’ll see that it’s all on one line. PHP is printing the source code of your HTML file - therefore a  
> will become a newline in the source code. A \<br/\> (XHTML strict version of \<br\>) in the source code of a HTML file will result in a newline on the HTML page, but a newline in the source code won’t.

I understand now. And thanks for the \<br/\> explaination as well. It works now. 🙂

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 8:40am UTC](https://forum.kirupa.com/t/php-newline-character-doesnt-work/116948/7 "2004-07-23T08:40:32Z")

</div>

Anytime 🙂
