Jump to content

new to php


coder13

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.