html escaping in PHP Posted Aug 14, 2025 Updated Aug 14, 2025 By Victor Elgersma 1 min readUse htmlspecialchars() for this: 1 2 php > echo htmlspecialchars("<script>"); <script> This will prevent (most) XSS attacks. php This post is licensed under CC BY 4.0 by the author. Share