Is there a recommended approach in PHP to avoid adding slashes automatically before special characters?

When working with user input in PHP, special characters like quotes may be automatically escaped with slashes to prevent SQL injection attacks. However, this can cause issues when displaying the input as it may show extra slashes. To avoid this, you can use functions like stripslashes() to remove the slashes before displaying the input.

// Example of removing slashes before displaying user input
$userInput = "This is an example with a quote: O\'Reilly";
$cleanInput = stripslashes($userInput);
echo $cleanInput;