首先,请参考英文的 addslashes() 函数,它能达到你想要的功能,你也应参考PHP3.ini设定的 magic_quotes_gpc 选项。
函数 ereg_replace()可以达到你要的结果,做法如下: