What is the correct syntax for displaying text from a form in PHP without losing line breaks?

When displaying text from a form in PHP, the issue of losing line breaks often occurs due to the HTML `nl2br()` function not being used. This function converts newlines in a string to HTML line breaks, allowing the text to be displayed with proper formatting. To solve this problem, simply apply the `nl2br()` function to the form input before displaying it on the webpage.

<?php
// Retrieve text from form
$formText = $_POST['form_text'];

// Apply nl2br() function to preserve line breaks
$formTextWithLineBreaks = nl2br($formText);

// Display text with preserved line breaks
echo $formTextWithLineBreaks;
?>