Removing Extraneous Backslashes with PHP
This is something that most people who use PHP already know. I still think it is useful to mention it because some less experienced PHP coders might not have come across this function just yet and they will be grateful.
If you are displaying a string using PHP, sometimes you see something that looks like this, “I was over a my sister\’s place to celebrate my father\’s birthday…”. That is because PHP actually uses quotes for certain functions so when it encounters a quote in a string, is places the backslash “\” before it to signify that is should not be read as code, but as text. This usually happens with textarea boxed and can be easily avoided. extraneous
<?php stripslashes($string); ?> |
Now your string will display like this, “I was over a my sister’s place to celebrate my father’s birthday…”.



Just out of curiosity, if I running a WordPress site, where do I place this line of code? Is it in the wp-config?
Do not add it to wp-config.php. This function should wrap whatever text or string you plan on displaying that might have additional slashes. Both WP functions that display your content already have this function built in.