Re: Object Inheritance, get_class() and a static function call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



axel wrote:
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:

will take a deeper look this evening ... but ...



class onObject  {
 // ...   }


abstract class onAplObject extends onObject {

 protected static function registerVariable($key, $value) {

try making the function defintion like this:

protected function registerVariable($key, $value) {

and then use:

$theRealClassName = get_class($this);

otherwise the simplest solution maybe to do:

protected static function registerVariable($obj, $key, $value) {

and then:

$theRealClassName = get_class($obj);

which is a little clumsy but will work!



    $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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux