I'm having a problem where on a server the output of var_dump
and print_r
come out entirely garbled. print_r
outputs pure gibberish (eg. ��]{W�8�����-
... etc), while var_dump
at least gives string (1664)
, followed by similar gibberish (though this time wrapped in double quotes).
This looks like a character encoding issue, but no encoding I can find seems to fix it (and I don't know why just dumping a PHP object should be outputting non-ascii characters anyway), and echo
works fine. Alternatively, I wonder if it could be a gzip issue. Either way, I suspect it must be something in PHP or Apache's configuration, but I have no idea how to fix it.
I'd be very grateful if anyone has any suggestions as to how fix this!
Update: on further investigation, it seems it's a problem specific to the particular object I'm trying to dump. The object in question is decoded JSON requested (via curl) from an API. Is it possible that either json_decode
or curl
could be misconfigured / mangling the encoding?