title: How to escape $ in PHP using preg_replace?
body: <p>I am using <code>preg_replace</code> to escape special characters:</p>
  
  <pre><code>$tmpStr=preg_replace("/\?/", "\?", $tmpStr);
  $tmpStr=preg_replace("/\#/", "\#", $tmpStr);
  $tmpStr=preg_replace("/\^/", "\^", $tmpStr);
  $tmpStr=preg_replace("/\&amp;/", "\&amp;", $tmpStr);
  $tmpStr=preg_replace("/\*/", "\*", $tmpStr);
  $tmpStr=preg_replace("/\(/", "\(", $tmpStr);
  $tmpStr=preg_replace("/\)/", "\)", $tmpStr);
  $tmpStr=preg_replace("/\//", "\/", $tmpStr); 
  </code></pre>
  
  <p>But I am not able to escape <code>$</code> using the same function:</p>
  
  <pre><code>$tmpStr=preg_replace("/\$/", "\$", $tmpStr);
  </code></pre>
  
  <p>And also when I use the above statement all the spaces get replaced by <code>$</code> and <code>$</code> is not getting escaped.</p>
  
  <p>How do I escape the dollar sign correctly?</p>