Click to See Complete Forum and Search --> : [RESOLVED] Works fine at the CLI, but not via Apache. Why?


Ravenous
12-17-2005, 07:38 PM
I installed a PHP module to let me work with the JSON format for some AJAX stuff I'm working on. I added the proper line to php.ini (extension=json.so), ensured that the extension directory was properly configured (extension_dir=/usr/local/lib/php/extensions/) and then restarted Apache to make use of these changes.

The extension gives me two functions, json_encode() and json_decode(). To test it out, I wrote a very simple script which I include here:<html><head></head><body>
<?php
$out = json_encode("success") or die("json_encode not working");
$val = json_decode($out) or die("json_decode not working");
echo $val;
?>
</body></html>I execute the script with my browser and, lo and behold, nothing. Blank page with nothing after the opening body tag. So I decide to try it out with PHP at the command line. Here's the output from that:# php -v
PHP 4.3.7 (cli) (built: Jul 11 2004 13:52:48)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
# php jsontest.php
<html><head></head><body>
success</body>
</html>
Look at that. It worked.

So here's the question. Why would an extension be available at the command line and not via Apache?

Ravenous
12-17-2005, 08:16 PM
Strangely enough, the third restart of Apache resolved the issue. Why, I do not know. If anyone has any insight into the problem, I'm still interested in knowing.