I am using preg_replace
to escape special characters:
$tmpStr=preg_replace("/?/", "?", $tmpStr);
$tmpStr=preg_replace("/#/", "#", $tmpStr);
$tmpStr=preg_replace("/^/", "^", $tmpStr);
$tmpStr=preg_replace("/&/", "&", $tmpStr);
$tmpStr=preg_replace("/*/", "*", $tmpStr);
$tmpStr=preg_replace("/(/", "(", $tmpStr);
$tmpStr=preg_replace("/)/", ")", $tmpStr);
$tmpStr=preg_replace("///", "/", $tmpStr);
But I am not able to escape $
using the same function:
$tmpStr=preg_replace("/$/", "$", $tmpStr);
And also when I use the above statement all the spaces get replaced by $
and $
is not getting escaped.
How do I escape the dollar sign correctly?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…