Hello,

I wonder why this code won't work:

HomeController.php

$content = $email."\n".$phone."\n".$select;

I expect that it goes to the next line after \n

when you set header("Content-Type:text/plain"); or use it inside pre echo '<pre>'.$content.'</pre>;` then it should be work fine

commented: Good advice +15
Member Avatar
diafol

Just like to add - I'm seeing a lot of issues with \n lately. If you use this as part of general html output, it will help to prettify the underlying html (e.g. see source view), but very little else. To actually see the newline as part of output to the screen, you need to do as shown by AndrisP. Be aware \n is not the same as the html <br />.

You could always use the PHP_EOL constant, which is a better platform-independent fit IMO:

$content = $email.PHP_EOL.$phone.PHP_EOL.$select;

I don't understand where to write:

header("Content-Type:text/plain");

I already try place it in the HomeController.php (the space does not work) and email.blade.php template (it actually prints the codes).

I also try using PHP_EOL, it only shows a space instead going to the next line which I expect.

Member Avatar
diafol

Do you need a text newline or a html break?

Member Avatar
diafol

HomeController not the place to put this I wouldn't think. Shouldn't it be in your email template?
Makes sense to make that plain text.