PHP Classes

PHP5 compatability

Recommend this page to a friend!

      DrasticTools  >  All threads  >  PHP5 compatability  >  (Un) Subscribe thread alerts  
Subject:PHP5 compatability
Summary:By including json encode your users will need 5.2.0 or higher
Messages:4
Author:nlstart
Date:2007-04-11 11:37:58
Update:2007-05-01 12:51:29
 

  1. PHP5 compatability   Reply   Report abuse  
Picture of nlstart nlstart - 2007-04-11 11:37:58
From http://de2.php.net/json_encode:
json_encode
(PHP 5 >= 5.2.0, PECL json:1.2.0-1.2.1)

In drasticCommon.class.php you use on line 56:
json_encode($GLOBALS['drasticsettings'])

this means the tool will only work from PHP version 5.2.0 and higher.
I would be happy to use this tool with 5.1 or even 4.4.4 which are still very common amongst large user communities (and even providers!)

  2. Re: PHP5 compatability   Reply   Report abuse  
Picture of nlstart nlstart - 2007-04-11 12:08:26 - In reply to message 1 from nlstart
As was stated correctly in the Prerequisites of DrasticTools.txt:
- Json installed (see http://www.json.org), Json is installed by default in the latest php release.

Sorry, I should have read this readme first...

By the way, by using your ported PHP4 version I cannot update and delete records (when using PHP 5.1).

  3. Re: PHP5 compatability   Reply   Report abuse  
Picture of dd dd - 2007-04-11 17:31:46 - In reply to message 2 from nlstart
yes, you are right JSON install is necessary.
json.org explains possibilities to add JSON support if you don't have a PHP version with it installed by default, but of course the most easiest way is to install a PHP version with JSON support.

PHP4 version: well, someone else added this port and it used to work for him. I am not familiar with the port itself, so cannot advise you on this one.

  4. Re: PHP5 compatability   Reply   Report abuse  
Picture of Rich Rich - 2007-05-01 12:51:29 - In reply to message 3 from dd
I have also run into this problem. There is a fairly simple solution, though. Download the JSON PEAR package ( http://pear.php.net/pepr/pepr-proposal-show.php?id=198 ) and install it. Then you'll need to add the following into the constructors for drasticMySQL.class.php and drasticCommon.class.php.

include_once 'Services/JSON.php';
$json = new Services_JSON();
$this->json = $json;

Then, change all instances of 'json_encode' to '$this->json->encode' and you should be good. Let me know if you have any problems with this, as I might have missed something.