Author Topic: Local vs Server anomaly  (Read 553 times)

Pat

  • Guest
Local vs Server anomaly
« on: February 14, 2012, 08:23:05 PM »
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 Code: [Select]

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($jsontrue)); //again, no love..


ErnieAlex

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 1847
  • Karma: 32
    • View Profile
Re: Local vs Server anomaly
« Reply #1 on: February 15, 2012, 09:02:36 AM »
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 <script></script> 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...
« Last Edit: February 15, 2012, 09:08:58 AM by ErnieAlex »

patowens

  • New Member
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
Re: Local vs Server anomaly
« Reply #2 on: February 15, 2012, 03:26:30 PM »
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.


ErnieAlex

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 1847
  • Karma: 32
    • View Profile
Re: Local vs Server anomaly
« Reply #3 on: February 15, 2012, 03:49:04 PM »
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...