New line not working...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
orbdrums
Forum Commoner
Posts: 82
Joined: Wed Sep 14, 2011 11:42 pm

New line not working...

Post by orbdrums »

This code does not seem to want to display a new line with echo. Any suggestions would be appreciated.

<?php
$to = "To: example@test.net";
$subject = "\nSubject: Test";
$message = "\nMessage: hello";
$headers = "\nFrom: webmaster@example.com" .
"\nReply-To: webmaster@example.com" .
"\nX-Mailer: PHP/" . phpversion();

echo $to, $subject, $message, $headers;

?>
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: New line not working...

Post by Celauran »

Line breaks don't show in HTML; this is normal. Wrap it in <pre> tags, or use nl2br
orbdrums
Forum Commoner
Posts: 82
Joined: Wed Sep 14, 2011 11:42 pm

Re: New line not working...

Post by orbdrums »

I used the <pre> tags and that worked great. Thanks!
Post Reply