Re: Json.php
| From: | Roman Neuhauser | Date: | Wed, 18 Apr 2007 09:27:46 +0000 |
| Subject: | Re: Json.php | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-253186@lists.php.net to get a copy of this message | ||
# chris.boget@wild.net / 2007-04-18 04:59:48 -0400:
> >So only one of these is "kosher"
> >static:
> >return Services_JSON::decode($data);
> >
> >class:
> >$json = new Services_JSON;
> >return $json->decode($data);
> >but not both.
>
> I'm not trying to start (or further add fuel to) any kind of war but
> instead an earnest question: why not both?
If you don't declare the method static, you might be using $this inside,
possibly indirectly.
class c
{
function f()
{
if (its_second_friday_this_year()) {
return get_class($this);
}
return 'mostly harmless';
}
function g()
{
return self::f();
}
}
c::g();
That's an incident waiting to happen, and forbidding static calls of
instance methods is an (intended) anti-footshooting measure.
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991