How to replace single and double quotes You can use addslashes addslashes will do the trick. It will return a new string with the all the quotes ( ' and " ) with their escaped counterparts.