title: str_replace double and single quotes
body: <p>I have a simple PHP script that should escape both single and double quotes with a backslash. Here is my code:</p>
  
  <pre><code>$output = str_replace('"','\"',$input);
  $output = str_replace("'","\'",$output);
  return $output;
  </code></pre>
  
  <p>Problem is, it only escapes the double quote, so a string like </p>
  
  <pre><code>"This" is a 'string'
  </code></pre>
  
  <p>parses out to be</p>
  
  <pre><code>\"This\" is a 'string'
  </code></pre>
  
  <p>not</p>
  
  <pre><code>\"This\" is a \'string\'
  </code></pre>
  
  <p>If I change the second line to </p>
  
  <pre><code>$output = str_replace("'","asdf",$output);
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>\"This\" is a asdfstringasdf
  </code></pre>
  
  <p>Any ideas what is going wrong?</p>
  
  <p>Thanks</p>