OK, one possible answer to your problem is using debug_bactrace in the
following form:
class Foo {
public static function getStaticCallingClass(){
$debugArray = debug_backtrace();
$className = $debugArray[2]['class'];
return $className;
}
public static function A(){
$className = self::getStaticCallingClass();
eval($className . "::B();");
}
public static function B(){
echo "Foo";
}
}
class Bar extends Foo {
public static function B(){
echo "Bar";
}
}
The problem of handling the access of inherited static members and
functions is probably a common one in PHP5.
It is a matter of philosophy of the language.
But I do believe there should be a token which easily addresses this in
PHP5.
-------------------------------------
porneL wrote:
How do I use static functions/properties with inheritance? I've found
it
very problematic.
class Foo
{
static function A() {/* ??? */::B(); }
static function B() {echo 'Foo';}
};
class Bar extends Foo
{
static function B() {echo 'Bar';}
}
I'd like Bar::A() to respect inheritance and output 'Bar', but I
can't
figure out how to make call from base class to static methods of
inherited
class.
Is there equivalent of $this for static calls? Or something being
reverse
of 'parent'?
##-----------------------------------------------#
Article posted with Web Developer's USENET Archiv
http://www.1-script.com/forum
no-spam read and post WWW interface to your favorite newsgroup -
comp.lang.php - 21435 messages and counting
##-----------------------------------------------##