简体   繁体   中英

PHP Echo does not include line spacing

<textarea cols="60" rows="10" type="text" name="inputMessage" value="" </textarea> </textarea> <br>

$message = $_POST['inputMessage'];
echo $message;

When the inputMessage is:
lorem ipsum dolor
lorem ipsum dolor

It prints it without line spacing. like 'lorem ipsum dolor lorem ipsum dolor'

$message = nl2br($_POST['inputMessage']);
echo $message;

Should do the trick, nl2br documentation .

Someone posted the answer, but I assume he deleted it since it doesn't exist anymore after I refreshed the page.

The solution was this:

echo nl2br($message);

Other solutions may produce double-line-spacing even if there just one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM