What are the potential issues with displaying line breaks in PHP text input fields and how can they be resolved?

When displaying text input fields in PHP, line breaks may not be rendered properly, resulting in a messy and unreadable display. To resolve this issue, you can use the nl2br() function in PHP to convert newline characters into HTML line breaks, ensuring that the text is displayed correctly with proper line breaks.

<?php
$text = "Hello\nWorld!";
echo nl2br($text);
?>