What is the purpose of using addslashes() and strip_tags() functions in PHP and how do they affect the output?

When dealing with user input in PHP, it is important to sanitize the data to prevent potential security vulnerabilities. The addslashes() function is used to escape special characters in a string, which helps prevent SQL injection attacks. On the other hand, the strip_tags() function is used to remove HTML and PHP tags from a string, which helps prevent cross-site scripting (XSS) attacks.

// Example of using addslashes() and strip_tags() functions to sanitize user input
$user_input = "<script>alert('XSS attack!')</script>";
$clean_input = strip_tags(addslashes($user_input));

echo $clean_input;