Is it necessary to use HTML Purifier for every input field or only for text areas with TinyMCE, when dealing with XSS protection in PHP?

To protect against XSS attacks in PHP, it is recommended to use HTML Purifier on all user input fields, not just text areas with TinyMCE. This is because malicious scripts can be injected through any input field, including text inputs, checkboxes, radio buttons, etc. By using HTML Purifier on all input fields, you can ensure that any potentially harmful code is sanitized before being displayed on your website.

require_once 'HTMLPurifier/HTMLPurifier.auto.php';

$config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);

$clean_input = $purifier->purify($_POST['user_input']);