Stig,

On Tue, 2004-02-03 at 17:27, Stig S. Bakken wrote:
> Try __CLASS__.

Thank you for the reply.  This does work for the class the method is
defined in, however unfortunately it's not a solution for classes that
inherit this method.  Here's the sample code I used in my first post:

class Foo { 
 function getClassName() {
  // ???
 }
}
class Bar extends Foo {
}

echo Foo::getClassName();  // returns 'foo'
echo Bar::getClassName();  // returns 'bar'

The solution I have right now that is inheritable, though very kludgy is
this:

class Foo { 
 function someFunc($class_name) {
  return $class_name;
 }
} 
class Bar extends Foo {
 function someFunc($class_name = NULL) {
  return parent::someFunc(isset($class_name) ? $class_name : __CLASS__);
 }
}

This does work, but I have to have this stub function copied into every
class that inherits Foo, plus I have an extra parameter in there.  Is
there no better way?

Thanks again,
Adam

-- 
Adam Bregenzer
[EMAIL PROTECTED]
http://adam.bregenzer.net/

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

Reply via email to