M
M
Mobyman2011-02-05 23:04:48
CodeIgniter
Mobyman, 2011-02-05 23:04:48

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

When using the helper for Code Igniter, an error occurs:
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

7 answer(s)
M
Mobyman, 2011-02-06
@Mobyman

I found an alternative for myself , if anyone suddenly encounters the same. Thanks to all.

N
Nodge, 2011-02-05
@Nodge

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.

M
MT, 2011-02-06
@MTonly

Write to the technical support of the hosting provider so that they compile the full (with the included JSON extension) version of PHP.

D
Dmitry Serzhenko, 2011-02-06
@Serzhenko

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.

R
Rafael Hovhannisyan, 2013-11-23
@hosembafer

http://habrahabr.ru/post/198312/

E
Eugene, 2011-02-06
@Nc_Soft

Are there any other bikes? It's better to leave this hosting.

Z
zizop, 2011-02-06
@zizop

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 question

Ask a Question

731 491 924 answers to any question