Re: Object Inheritance, get_class() and a static function call
| From: | axel | Date: | Wed, 27 Jul 2005 09:40:09 +0000 |
| Subject: | Re: Object Inheritance, get_class() and a static function call | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-219404@lists.php.net to get a copy of this message | ||
Hello Jochem,
Axel lets start again.Okay.
SO: explain, please, why and what you are trying to do (DETAILS!). don't dumb it down because that just makes the problem look moot.I need the classname to register variables in the session. It's complicated. There are a lot of inheritences. Please take a look at the code: class onObject { // ... } abstract class onAplObject extends onObject { protected static function registerVariable($key, $value) {
$theRealClassName = ???;
# $theRealClassName = get_class($this);
# output is --> Undefined variable: this in ...
# $theRealClassName = get_class(self);
# output is --> Notice: Use of undefined constant self ...
# $theRealClassName = __CLASS__; # => $theRealClassName=="onAplObject"
# $theRealClassName = debug_backtrace()[1]['class'];
# => $theRealClassName=="onDbTableEdit"
# $theRealClassName = debug_backtrace()[0]['class'];
# => $theRealClassName=="onAplObject"
$_SESSION[$theRealClassName.'_'.$key]=$value;} } class onDbTableEdit extends onAplObject { public static function show() { self::registerVariable("listsort", "id"); } } class onUseradmin extends onDbTableEdit { // .... } onUseradmin::show(); Best regards Axel