There is a server on which version php 4.4 is installed, there is no sense in transferring to a higher version of php-very old site. Screw the sms gateway, rewrote a little classes to work with him. Faced the problem that there are no json_decode and json_encode functions. Can someone come across and be able to help find a solution to the problem? Thank.

  • one
    @Nick Volynkin, do you suggest copying the PECL package installation instructions? pecl install json? Or is the reward specifically meant to stimulate FreeDooM? - Fine
  • and why the answer is not exhaustive? really helped ... it was written that a little bit of remaking was done for my specific task ... I consider it a completely normal answer - Boris Runs
  • @ A small reward was for anyone who would take the trouble to bring the answer in order. - Nick Volynkin
  • @BerezhimovBoris answer was just a link, so of course not exhaustive. - Nick Volynkin

2 answers 2

Will have to be screwed by hand:

Using the library below, you need to check and determine if there are no conversion methods:

if (!function_exists('json_decode')) { function json_decode($content, $assoc=false) { require_once 'classes/JSON.php'; if ($assoc) { $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); } else { $json = new Services_JSON; } return $json->decode($content); } } if (!function_exists('json_encode')) { function json_encode($content) { require_once 'classes/JSON.php'; $json = new Services_JSON; return $json->encode($content); } } 

Link to the library: http://mike.teczno.com/JSON/JSON.phps

Taken from: http://www.epigroove.com/blog/how-to-use-json-in-php-4-or-php-51x

  • Thank you) exactly what you need - Boris Pobezhimov

The original PECL package , which was later moved to the PHP core, declares support from PHP 4.3. Try it and put it.