title: How to json_encode $GLOBALS?
body: <p>I'm trying to debug a PHP application, and as a section of the debug process, I passed print_r($GLOBALS) through the AJAX request to my browser.  However, I'd prefer to see it in native JSON form because it comes out better in the browser.  I'm trying to use the following snippet of code:</p>
  
  <pre><code>json_encode($GLOBALS);
  </code></pre>
  
  <p>but I've found it returns bool(false).  The <a href="http://us2.php.net/json_encode" rel="nofollow" title="json_encode documentation">JSON documentation</a> says "Returns a JSON encoded string on success <em>or FALSE on failure.</em>"  But what about $GLOBALS makes it fail?  Is it the recursive $GLOBALS['GLOBALS']?</p>
  
  <p>I was thinking as an alternative to loop over $GLOBALS and put that in an array, but that seems quite pointless when the point of json_encode is to encode an array.</p>