json_encode returns internal server error

Hi! I’m having a problem with this simplified code - json_encode function, to be precise.


$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);

echo json_encode($arr);

This script works on my local server without any problem, however when I upload it to my remote server, I get “500 Internal Server Error”. What could be the cause of this, any ideas? Maybe some server config?

From php.net (though I don’t see anything that should look like a 500 Internal Server Error)

Note:

In the event of a failure to encode, json_last_error() can be used to determine the exact nature of the error.

Is is any more code to your file than what you pasted?

Also check what version of PHP your server is running using phpinfo()

Version of PHP/PECL json library matters…