How to create a newline character (line break) in PHP?
Hello! I just started learning PHP and encountered a problem when outputting text. I need the text to display with line breaks in the browser, but I can't get it to work.
Here is my code:
```php
```
I expected to see:
Line 1
Line 2
Line 3
But in the browser it displays everything on one line: "Line 1 Line 2 Line 3". I tried writing , \\r, but the result is the same.
Then I tried using double quotes and single quotes — no difference. I read that PHP has special characters, but they don't work.
Maybe I'm confusing something? I know that HTML has the
tag, but I need it specifically in PHP code, so I can later write it to a file or send it via email. Please explain how to do line breaks correctly.
tag, but I need it specifically in PHP code, so I can later write it to a file or send it via email. Please explain how to do line breaks correctly.
No answers yet.
Log in to leave an answer