How should text with line breaks be displayed when retrieved from a MySQL table using PHP?

When retrieving text with line breaks from a MySQL table using PHP, the line breaks may not be displayed correctly in the browser. To ensure that the line breaks are properly displayed, you can use the PHP nl2br() function to convert newline characters to HTML line breaks (<br> tags).

// Retrieve text with line breaks from MySQL table
$text = $row[&#039;text&#039;];

// Display text with line breaks converted to HTML
echo nl2br($text);