Local vs Server anomaly

Hi all, I’m beginning to make small simple app using PHP. I’ve started this locally using an Xampp setup.

Using the JSON decode function and var_dump is working fine on my local, however, this code doesn’t execute when on the server. All other PHP code excutes fine… I can echo, print, work with variables etc…

My question is, is there something perhaps in my servers installation/configuration that would affect:
JSON_decode() and var_dump() from executing?

[php]
echo “hello world”; //this displays fine on local or server.

$json = ‘{“a”:1,“b”:2,“c”:3,“d”:4,“e”:5}’;

var_dump(json_decode($json)); //no love…
var_dump(json_decode($json, true)); //again, no love…

[/php]

Hmmm, You are aware that JSON stands for Javascript Object Notation.
Your echo command looks like a PHP command and should display SERVER-SIDE which is then
shown when the PHP is posted back to HTML inside the browser.

BUT, JSON is CLIENT-SIDE. It is Javascript. It runs in the browser inside etc.

*** Sorry, I did some further research… JSON is basically just a way to format data which can be passed as an object. Here is a way to do it within PHP:
http://php.net/manual/en/book.json.php

Hope that helps…

Thanks for the reply. It got me thinking. However, the JSON decode php function should be working regardless because I has supplied the JSON formatted string in a variable for its server side use.

From that link, I stumbled on this. It could be my problem:

[quote]On one server I use (FreeBSD 6.3; PHP 5.2.6 as module in Apache 2.2.10), PHP was compiled with the ‘–disable-all’ configuration option. Consequently, there exists a secondary configuration file – /usr/local/php5/etc/extensions.ini – in which the line

; extension=json.so

must be uncommented (delete the semicolon) and Apache restarted for these functions to be available.

Hmmm, I hope that works for you. If it doesn’t, let us know. There was a lot of info on that link I posted earlier. I am still reading posts there. It seems there are a lot of people having problems with this problem. A lot of them have solved it in different ways. But, a lot of reading… Let us know…

Sponsor our Newsletter | Privacy Policy | Terms of Service