title: PHP JSON functions not available while being called as CLI script?
body: <p>Just noticed something, but I'm not sure why this is true, or why it is different than a standard script, maybe someone can help me solve this riddle. When running a PHP script that contains a <code>json_*</code> function from the command line as an executable I will get a <code>Fatal error: Call to undefined function json_encode() in /var/www/jsontest.php on line 6</code> with the script below</p>
  
  <pre><code>#!/usr/bin/php -n
  &lt;?php
  
  $arr = array('foo', 'bar', 'baz');
  
  print_r($json = json_encode($arr));
  print_r(json_decode($bar));
  </code></pre>
  
  <p>This also happens with json_decode() when trying to decode standard clean json input (validated via jsonlint)</p>
  
  <p>The above script was being run as follows, in a Linux/DEB terminal...</p>
  
  <pre><code>$ chmod +x jsontest.php
  $ ./jsontest.php
  </code></pre>
  
  <p>By running this through my local webserver though, I receive my expect output</p>
  
  <pre><code>#!/usr/bin/php -n ["foo","bar","baz"]Array ( [0] =&gt; foo [1] =&gt; bar [2] =&gt; baz ) 
  </code></pre>
  
  <p>What is going on? Why is JSON not available when interpreted as an executable? </p>
  
  <p>PHP version is <code>PHP 5.5.3-1ubuntu2 (cli) (built: Oct  9 2013 14:49:24)</code> and PHPInfo for anyone who might want it is published on my <a href="http://ubuntuone.com/3FPLxRpQ50Gpcwod9fB3Pm" rel="nofollow">Ubuntu One Account</a></p>