How can PHP be used to preserve HTML tags in text retrieved from a database without rendering them as styled content?

When retrieving text from a database that contains HTML tags, PHP may render them as styled content instead of displaying them as plain text. To preserve the HTML tags without rendering them, you can use the `htmlspecialchars()` function in PHP. This function converts special characters to HTML entities, preventing the browser from interpreting them as HTML tags.

<?php
// Retrieve text from the database
$text = "<p>This is a <strong>sample</strong> text with HTML tags.</p>";

// Preserve HTML tags without rendering them
$preservedText = htmlspecialchars($text);

// Display the preserved text
echo $preservedText;
?>