-1

trying to get php to give me new lines and its not working even after goggling around. I'm using the \r\n and it does not display but also does not give me a new line carriage return.

Any suggestions would be greatly appreciated!

<?php
if (!$socket = @fsockopen("xxx.xxx.xxx.xxx", 22, $errno, $errstr, 1))
{
   echo "<font color='red'><strong>servername.domain.com(xxx.xxx.xxx.xxx) is Offline!\r\n</strong></font>";
}
else
{
echo "<font color='green'><strong>servername.domain.com(xxx.xxx.xxx.xxx) is Online!\r\n</strong></font>";
fclose($socket);
}
if (!$socket = @fsockopen("xxx.xxx.xxx.xxx", 22, $errno, $errstr, 1))
{
   echo "<font color='red'><strong>servername2.domain.com(xxx.xxx.xxx.xxy) is Offline!\r\n</strong></font>";
}
else
{
    echo "<font color='green'><strong>servername2.domain.com(xxx.xxx.xxx.xxy) is Online!\r\n</strong></font>";
fclose($socket);
}
?>
user1601716
  • 1,893
  • 4
  • 24
  • 53

4 Answers4

2

If you are running page through browser then user <br> html tag and you are running script through command prompt then use \n

Nanhe Kumar
  • 15,498
  • 5
  • 79
  • 71
0

Try <br> instead of \n. because \n is not recognized by HTML

The Mighty Programmer
  • 1,242
  • 12
  • 23
0

As you are looking to write to an HTML format, it would be best if you used
to force a new line.

Charlie74
  • 2,883
  • 15
  • 23
0

try with

**<br>**

if /n already come from database try nl2br

sumit
  • 15,003
  • 12
  • 69
  • 110