You are here: Re: [PHP] Object Inheritance, get_class() and a static function call « PHP « IT news, forums, messages
Re: [PHP] Object Inheritance, get_class() and a static function call

Posted by Jochem Maas on 09/27/49 11:22

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
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация