// PHP 7 htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); // PHP 8 // Specify only required parameters, skipping optional ones. // Arguments are order-independent and self-documented. htmlspecialchars($string, double_encode: false);
That’s it!. Please share your thoughts or suggestions in the comments below.