What is the purpose of using stripslashes(addslashes($var)) in PHP code?

When dealing with user input in PHP, it is important to sanitize the data to prevent SQL injection attacks. Using addslashes() adds escape characters to special characters in a string, while stripslashes() removes these escape characters. By using stripslashes(addslashes($var)), we can ensure that the user input is properly sanitized and safe to use in SQL queries.

$var = "User's input with special characters";
$var_sanitized = stripslashes(addslashes($var));
// Now $var_sanitized can be safely used in SQL queries