Jump to content

Recommended Posts

The newline character is working in regard to your generated output (look at your source code in the browser).  The 'problem' is that you're looking at it with the browser.  To a browser, an HTML line break element (<br>) is what will make a new line visible on the screen.

 

In other words, your generated code is:

 

my string
my other string

 

But since browsers ignore white space, it's being displayed as:

 

my stringmy other string

 

To make it look right in the browser, swap \n for <br>

Link to comment
https://forums.phpfreaks.com/topic/232286-new-to-php/#findComment-1194960
Share on other sites

The "\n" is not the newline on the browser display. To the browser, that character is another whitespace character. To get a newline on the browser, you need to use the HTML tag "<br>". If you had looked at the source, you would have seen the newline between those strings:

<?php
$str = "my string";
$str1 = "my other string";
echo $str;
echo "<br>";
echo $str1;
?>

or

<?php
$str = "my string";
$str1 = "my other string";
echo "$str<br>$str1";
?>[code]

Ken

Link to comment
https://forums.phpfreaks.com/topic/232286-new-to-php/#findComment-1194962
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.