How can HTML formatting be properly displayed when retrieving text from a MySQL database in PHP?

When retrieving text from a MySQL database in PHP that contains HTML formatting, the HTML tags may not be displayed properly in the browser. To ensure that the HTML formatting is displayed correctly, you can use the `htmlspecialchars_decode()` function in PHP to decode the HTML entities before outputting the text.

// Retrieve text from MySQL database
$text = $row['text'];

// Decode HTML entities to display HTML formatting
echo htmlspecialchars_decode($text);