title: Correctly escaping a string in php before passing it to javascript
body: <p>Ok so i have an input field that generates some text in html form (yea, don't ask). I set it as a php variable and then try to display it in a colorbox pop-up.</p>
  
  <p>My text, as generated:</p>
  
  <pre><code>$text = '&lt;h1&gt;Some title&lt;/h1&gt;&lt;p&gt;Some text&lt;/p&gt;';
  </code></pre>
  
  <p>And i try to use it like so:</p>
  
  <pre><code>$.colorbox({html:"'.$text.'"});
  </code></pre>
  
  <p>Obviously the js breaks as i would need to escape my string somehow. Tried htmlspecialchars() and alike but it does not help.</p>
  
  <p>Thanks, and apologies for (i feel) incredibly noobie question.</p>