Why \ n doesn’t work on one line of my PHP script, but works fine with everyone else?

I am writing an email to send when I submit the form. For some reason, the character is \ndisplayed correctly on all lines except one. I do not see any difference between this line and others, so I can not understand why it does not work. Below is the code, as well as the output I get, as well as a list of the variables used.

As you can see from the letter, \nat the end of the line "Work Address" does not work, therefore, "Company Name" simply follows directly, and not on the next line. Then \nafter the company name it works fine, so the home address is on the next line.

Here is the code for the message:

$xmsg = "First Name: $firstname\n" .
        "Last Name: $lastname\n" .
    "Work Tel: $worktel\n" .
    "Home Tel: $hometel\n" .
    "Mobile Tel: $mobtel\n" .
    "E-mail: $email\n" .
    "Work Address: $workad\n" .
    "Company Name: $company\n" .
    "Home Address: $homead\n" .

Here's the conclusion:

First Name: Joe
Last Name: Bloggs
Work Tel: 0123456789
Home Tel: 0987654321
Mobile Tel: 0789456123
E-mail: joe.bloggs@jb.co.uk
Work Address: Bloggoffice, Joe Street, London, N1 J0E Company Name: 
Home Address: 9 Blogg Street, Borough of Joe, London, SE4 J03

, , :

$firstname = $_SESSION['firstname'];
$lastname = $_SESSION['lastname'];
$worktel = $_SESSION['worktel'];
$hometel = $_SESSION['privtel'];
$mobtel = $_SESSION['mobtel'];
$email = $_SESSION['email'];
$company = $_SESSION['companyname'];
$workad = $_SESSION['workad1'] . ', ' . $_SESSION['workad2'] . ', ' .     $_SESSION['workad3'] . ', ' . $_SESSION['workpostcode'];
$homead = $_SESSION['homead1'] . ', ' . $_SESSION['homead2'] . ', ' . $_SESSION['homead3'] . ', ' . $_SESSION['homepostcode'];

, , , !

+5
1

PHP_EOL , \n. PHP_EOL - .

+1

All Articles