What are the differences between handling line breaks in PHP and HTML when processing textarea input?

When processing textarea input in PHP, line breaks are represented as "\n" characters. However, when displaying this input in HTML, line breaks are represented by the <br> tag. To properly handle line breaks, you need to convert "\n" characters to <br> tags when displaying the input in HTML.

$text = $_POST[&#039;textarea_input&#039;]; // Get the textarea input

// Convert line breaks to &lt;br&gt; tags for HTML display
$html_text = nl2br($text);

echo $html_text; // Display the textarea input with line breaks converted to &lt;br&gt; tags