Are there best practices for cleaning up user input in PHP to prevent errors like extra slashes in URLs?

When dealing with user input in PHP, it's important to sanitize and clean the data to prevent errors like extra slashes in URLs. One way to do this is by using the `stripslashes()` function to remove any unnecessary slashes that may have been added. This function can be applied to user input before using it in URLs to ensure they are formatted correctly.

$userInput = $_POST['user_input'];
$cleanedInput = stripslashes($userInput);

// Now you can use $cleanedInput in your URL without worrying about extra slashes