-2

I have the following code:

$txt = "Name: \n" . $_POST["name"] .
"\r\n Company: " . $_POST["company"] .
"\r\nEmail: " . $_POST["email"] .
"\r\nPhone: " . $_POST["phone"] .
"\r\nCategory: " . $_POST["category"] .
"\r\nDescription: " . $_POST["desc"];

echo $txt;

and the output is:

Name: Bob Company: Bob\'s company Email: bob@bob.com Phone: 1231231234 Category: Automation Description: This isn\'t working

With no new lines. Could someone please point out what I am doing incorrectly?

chris85
  • 23,846
  • 7
  • 34
  • 51
Nick Suwyn
  • 501
  • 1
  • 5
  • 21
  • Because you probably look at the html output, so also use html tags, like: `
    `..
    – Rizier123 Jul 24 '15 at 15:41
  • I'd suggest switch over to ['PHP_EOL`](http://stackoverflow.com/questions/128560/when-do-i-use-the-php-constant-php-eol) instead of "hardcoded" line breaks. – Andrei Jul 24 '15 at 15:41
  • look at your HTML source - wink - they're there alright. – Funk Forty Niner Jul 24 '15 at 15:43
  • `\n` are only for writing to files which will put that under a new line. You're probably wanting to send an email, but didn't choose the right encoding for it. who knows what you *really* want to do here. Show us your real code and the real use for it – Funk Forty Niner Jul 24 '15 at 15:44
  • possible duplicate of http://stackoverflow.com/questions/128560/when-do-i-use-the-php-constant-php-eol – Funk Forty Niner Jul 24 '15 at 15:51

1 Answers1

0

To break line in HTML use <br/>.

Would recommended using PHP_EOL.

Here is the link:

When do I use the PHP constant "PHP_EOL"?

Community
  • 1
  • 1
Samir Selia
  • 7,007
  • 2
  • 11
  • 30
  • I wouldn't have submitted an answer for this. Not till I know exactly what the OP wants to use it for. Plus, it's already been stated in comments and OP isn't responding. Not yet anyway. – Funk Forty Niner Jul 24 '15 at 15:47