What are the potential pitfalls of using line break characters within a string variable in PHP?

Using line break characters within a string variable in PHP can lead to formatting issues when displaying the string, especially in HTML output where line breaks may not be rendered as expected. To solve this issue, you can use the PHP function `nl2br()` to convert newline characters to HTML line breaks `<br>` before outputting the string.

$string = &quot;This is a string with\nline breaks.&quot;;
echo nl2br($string);