title: inverted commas in javascript String
body: <p>Little confusion in filtering " inverted commas for a javascript string in php.</p>
  
  <pre><code>$data = "I'am a string my name is "String".";
  // problem is in following line.
  $data = str_replace("\"","\\". "\"",$data);
  
  $data = str_replace('&lt;br /&gt;','\n',$data);
  $data = str_replace("'","\\"."'",$data);
  
  $row['story'] = $row['story'] . "&lt;a href=\"#scroll\" onclick=\"addtext('$data'); return false\"&gt;Send&lt;/a&gt;";
  </code></pre>
  
  <p><strong>Update</strong>
  $data is some random string in a php page. I want to filter this string in simple text for a javascript function.e.g</p>
  
  <pre><code> $data = "I'am a string my name is \"String\".";
  </code></pre>
  
  <p>I want to get the results like this.</p>
  
  <pre><code>onclick="addtext('I\'am a string my name is "String"'); return false"
  </code></pre>