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


Now your string will display like this, “I was over a my sister’s place to celebrate my father’s birthday…”.

Share this:

Email
Facebook
Twitter
Pinterest
Pocket

Premium Themes for WordPress

Looking for an easy-to-use Premium Theme for WordPress? Check out Themes by bavotasan.com and have your site up and running in no time.

Use this WordPress website builder to build powerful websites in no time for your or your clients.

WordPress Hosting

WP Engine – designed from the ground-up to support and enhance the workflow of web designers.

Bluehost – providing quality web hosting solutions since 1996.

About the author

Picture of Luke Perrie

Luke Perrie