I'm not sure if this will work, but hey, you could give it a try.
class Car
{
public static $className = __CLASS__;
public static function drive ()
{
return self::$className;
}
}
class Porsche extends Car
{
public static $className = __CLASS__;
}
Hi list,
in PHP4 it was possible to get the name of the calling class with
debug_bcktrace(). Unfortunately this behaviour has been changed in PHP5. I
didn't find a solution in the archives.
Is there *any* way to get the name of the calling class?:
class Car {
function drive() {
// I
Not sure if this is the best way to do it or not, but you can do this
and it should (untested code) work.
class Car {
function drive() {
return $this-getClassName();
}
function getClassName() {
return Car;
}
}
class Porshe {
Christopher Fulton [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Not sure if this is the best way to do it or not, but you can do this
and it should (untested code) work.
class Car {
function drive() {
return $this-getClassName();
}
Torsten Roehr wrote:
Christopher Fulton [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Not sure if this is the best way to do it or not, but you can do this
and it should (untested code) work.
class Car {
function drive() {
return $this-getClassName();
}
5 matches
Mail list logo