title: php json_encode & jquery parseJSON single quote issue
body: <p>I searched and read most of the related topics, but they weren't what I was looking for.</p>
  
  <p>I've a JSON enocded string with <code>json_encode</code> PHP function:</p>
  
  <pre><code>{"casts":["Matthew Modine","Adam Baldwin","Vincent D'Onofrio"],"year":1987}
  </code></pre>
  
  <p>I'm working with jQuery to put the values in appropriate fields too, in the case of testing I did the below:</p>
  
  <pre><code>&lt;script&gt;
  var obj = jQuery.parseJSON('&lt;?=$data?&gt;');
  console.log(obj);
  &lt;/script&gt;
  </code></pre>
  
  <p>Suppose that $data is this:</p>
  
  <pre><code>$data =
  &lt;&lt;&lt;END
  {"casts":["Matthew Modine","Adam Baldwin","Vincent D'Onofrio"],"year":1987}
  END;
  </code></pre>
  
  <p>What Google chrome console produces in this case:</p>
  
  <pre><code>Uncaught SyntaxError: Unexpected identifier 
  </code></pre>
  
  <p>However when I make a change in JSON encoded string - adding <strong>Backslash</strong> to single quote :</p>
  
  <pre><code>{"casts":["Matthew Modine","Adam Baldwin","Vincent D\'Onofrio"],"year":1987}
  </code></pre>
  
  <p>Console output is as normal:</p>
  
  <pre><code>Object {casts: Array[3], year: 1987}
  casts: Array[3]
  year: 1987
  </code></pre>
  
  <p>The question: is this error in console expected? I think escaping or replacing <code>'</code> with <code>\'</code> will be so dirty!</p>
  
  <p><em><strong>UPDATED</em></strong></p>
  
  <p><em>Actually <strong>$data</strong> value comes from a <code>json_encode($var)</code> and $var is an array!</em></p>
  
  <pre><code>$data = json_encode($var);
  </code></pre>