How can HTML tags be disabled in user input in PHP?
To disable HTML tags in user input in PHP, you can use the strip_tags() function. This function removes any HTML and PHP tags from a string, leaving only the text content. By applying strip_tags() to user input, you can prevent users from injecting potentially harmful scripts or code into your application.
$userInput = "<p>Hello, <script>alert('XSS attack!');</script>World!</p>";
$cleanedInput = strip_tags($userInput);
echo $cleanedInput;
// Output: Hello, World!