Re: Json.php

From: Date: Wed, 18 Apr 2007 14:36:43 +0000
Subject: Re: Json.php
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-253193@lists.php.net to get a copy of this message
On 4/17/07, Richard Lynch <ceo@l-i-e.com> wrote:
On Mon, April 16, 2007 10:20 am, Tijnema ! wrote: And btw, I think it's better not to create a new link to the class each time the function is called, but just use :: if (!function_exists('json_encode')) {
       function json_encode($data) {
               return Services_JSON::encode($data);
       }
} and probably also one for decoding. if (!function_exists('json_decode')) {
       function json_decode($data) {
               return Services_JSON::decode($data);
       }
} Actually, if I understand the flame wars of Internals correctly, whichever one of those is correct, the other one ain't gonna work in PHP 6... Or so I gather from the OOP purists fighting the OOP zealots on PHP-Internals. I may be 100% wrong, of course, regarding not only the outcome of this flame-fest, but even if it applies to this JSON thingie.
I see that using the class static wouldn't work, because of the $this thing... I just tried, and working with Services_JSON::encode() doesn't work, while $json = new Services_JSON(); $json->encode() does work :) It's my fault, i thought there was only 2 functions inside the class, encode & decode. and that those functions were not using any other functions inside the class. Tijnema


« previous php.general (#253193) next »