Home / PHP Tips Generated By ChatGPT / Escaping Output for HTML in PHP Escape output to prevent XSS when displaying user input in HTML. Source Code echo htmlspecialchars($userInput, ENT_QUOTES, 'UTF-8');