0

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

3
Contributors
6
Replies
35
Views
10 Months
Discussion Span
Last Post by diafol
1

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

Votes + Comments
Good advice
1

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;
0

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.

0

Do you need a text newline or a html break?

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.