What is the best practice for loading a variable content into a textarea when the page is loaded in PHP?

When loading variable content into a textarea when the page is loaded in PHP, the best practice is to use htmlspecialchars to escape special characters and prevent potential security vulnerabilities like cross-site scripting (XSS) attacks. This ensures that the content is displayed correctly and safely within the textarea.

<?php
// Assuming $content contains the variable content to be loaded into the textarea
echo '<textarea>' . htmlspecialchars($content) . '</textarea>';
?>