Answer the question
In order to leave comments, you need to log in
JSON not working in PHP?
Hello, dear habra community.
I have a problem, I really hope that we will be able to solve it.
And the problem is that the json_encode() and json_decode() functions do not work on my hosting.
During normal use, an error occurs:
Fatal error: Call to undefined function json_encode() in ***.php
Message: Undefined variable: json
Filename: helpers/json_helper.php
Line Number: 53
Fatal error: Call to a member function encode() on a non-object in ...\system\application\helpers\json_helper.php on line 53
Answer the question
In order to leave comments, you need to log in
I found an alternative for myself , if anyone suddenly encounters the same. Thanks to all.
If possible, it is better to update php to version 5.2 or 5.3, then the json_encode() and json_decode() functions will work.
Otherwise, you need to look at what is there for an undeclared variable in CI, or use other implementations of these functions.
Write to the technical support of the hosting provider so that they compile the full (with the included JSON extension) version of PHP.
As a last resort, you can write analogues of the json_encode() and json_decode() functions yourself, if it is not possible to change the host and / or php delivery.
In this case, as a way out (without disassembly with the hoster), I can recommend using the
Zend_Json_Encoder classes and declaring the json_encode() and json_decode() functions in the global scope, inside which, respectively, call Zend_Json_Encoder::encode()/decode().
The method is certainly clumsy, but if there is no other option, then you can try.
See framework.zend.com/manual/en/zend.json.basics.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question