What are the best practices for handling line breaks in PHP when outputting content?

When outputting content in PHP, it's important to handle line breaks properly to ensure readability and consistency in the displayed text. One common approach is to use the PHP `nl2br()` function, which converts newlines to HTML line breaks. This function is useful when displaying text from a database or form input where line breaks are represented by `\n` or `\r\n`.

<?php
// Example text with line breaks
$text = "This is a line with\na line break.";

// Output the text with line breaks converted to HTML <br> tags
echo nl2br($text);
?>