From: news [mailto:[EMAIL PROTECTED] On Behalf Of 

> <code>
>    class Base  {
>       
>       static function f()   {
>          self::g();
>       }
> 
>       static function g()   {
>          print("Base\n");
>       }
>    }
> 
>    class Derived extends Base {
>       static function g()   {
>          print("Derived\n");
>       }
>    }
> 
>    Derived::f();
> </code>
> 
> I want that to print "Derived", but it prints "Base" instead. 
>  How can I get
> it to do what I want?
> 
> Thank for the help.

If you know the name of the extension class, you'd want to do this:

<code>
class Base {

        static function f() {
                Derived::g();
        }

        static function g() {
                print("Base\n");
        }
}

class Derived extends Base {
        static function g() {
                print("Derived\n");
        }
}

Derived::f();
</code>

If you don't know if, though, you could possibly call it as a variable.
Perhaps something like this:

<code>
class Base {

        static function f($classname) {
                $classname::g();
        }

        static function g() {
                print("Base\n");
        }
}

class Derived extends Base {
        static function g() {
                print("Derived\n");
        }
}

Derived::f('Derived');
</code>

Not sure if this is what you're looking for, but if not let us know.


-- 
Mike Johnson             Smarter Living, Inc.
Web Developer            www.smartertravel.com
[EMAIL PROTECTED]   (617) 886-5539

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to