|
Posted by Torsten Roehr on 10/03/22 11:05
> 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__;
> }
>
> Porche::drive(); // Should return "Porche"
Hi Daniel,
thanks for the idea but it causes an error:
Fatal error: Cannot redeclare property static public Car::$className in
class Porsche
If I ommit the definition of $className in Car I get this error:
Fatal error: Access to undeclared static property: Car::$className
If I ommit the definition of $className in Porsche the return value is 'Car'
not 'Porsche'. Arrrgh!
Will keep on trying.
Best regards, Torsten
Navigation:
[Reply to this message]
|