What are the common functions or methods in PHP that can be used to prepare HTML content for display in a user-friendly manner?

When preparing HTML content for display in a user-friendly manner in PHP, it's important to sanitize the input to prevent any potential security risks such as cross-site scripting (XSS) attacks. One common way to achieve this is by using the htmlspecialchars() function to convert special characters to HTML entities, ensuring that the content is displayed correctly in the browser without executing any malicious scripts.

// Example of using htmlspecialchars() to prepare HTML content for display
$htmlContent = "<h1>Welcome to our website!</h1>";
echo htmlspecialchars($htmlContent);