AWS SDK Json_encode (and namespaces)

So basics.
PHP 5.5.9 from the LAMP stack default from Ubuntu.
Run my script on CLI, runs fine.
Run it in a web browser, and it 500’s.
Apache error log says:
PHP Fatal error: Call to undefined function Aws\Api\Serializer\json_encode() in /var/www/html/vendor/aws/aws-sdk-php/src/Api/Serializer/JsonBody.php on line 44

json_encode (and decode() ) work in the standard namespace when called in a standalone script.

Not… sure why PHP is suddenly trying to look for a json_encode function in this namespace instead of using the one in it’s global function reference?

Also not sure how to fix it. Ideas?

Not sure because this never happened to me, but have you tried backslashing?


For me, this happens mostly with PDO and MySQLi_* if I use namespace. I usually just have to do

new \PDO


new \mysqli

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.