Fatal error: Call to undefined function json_encode() ..?

Im trying to use json with php and i keep getting the error

PHP Fatal error: Call to undefined function json_encode()

I am using php version 5.3.6 and on phpinfo(); nothing mentions json. Any suggestions?


For some reason your PHP was compiled without JSON. Either:

  • Recompile it
  • Install a package
  • Use a function that emulates json_encode, which can be found in the comments section of http://php.net/manual/en/function.json-encode.php

try in shell (assuming you are using linux),
otherwise refer to phpinfo();

php -i | grep json

example

php -i | grep json
json
json support => enabled
json version => 1.2.1

There is an interesting comment on the docs http://www.php.net/manual/en/json.requirements.php

If you're not seeing the json functions on 5.2.0 or newer, make sure php wasn't compiled with --disable-json