What are the advantages of using PHP functions like strip_tags() for sanitizing user input in forms?

When accepting user input in forms, it is important to sanitize the data to prevent potential security vulnerabilities such as cross-site scripting (XSS) attacks. PHP provides functions like strip_tags() that can be used to remove HTML and PHP tags from user input, ensuring that only plain text is accepted.

// Sanitize user input using strip_tags()
$user_input = "<script>alert('XSS attack!')</script>";
$clean_input = strip_tags($user_input);

// Output sanitized input
echo $clean_input;