== Quote from Greg Beaver ([EMAIL PROTECTED])'s article
> <?php
> class foo {
>      static function bar()
>      {
>       echo 'hello';
>      }
> }
>
> $bar = 'hello';
> $a = new foo;
> $a->bar(); // this could be disabled to error out easily
> $a::bar(); // my patch now allows this to print "hello"
> $a::$bar(); // this also works
> $a::{'bar'}(); // even this works
> ?>

The idea is good, but the syntax "$a::bar()" seems to me that $a is the name of the 
class, not an instance.

I would prefer that PHP supports:
  $class = get_class($a);
  $class::bar();
or, to make it shorter:
  get_class($a)::bar();

Anyway, if you need to call a class method, but you only know an instance of it, this 
is certainly because the class was not properly defined. A class method is a method 
that applies to the class, not instances. And a method that does not need to use $this 
is not necessarily a class method.

Stephane

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to