Removing Extraneous Backslashes with PHP
by Bandicoot Marketing on | Posted in Tutorials | 2 comments
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…”.
2 comments for “Removing Extraneous Backslashes with PHP”