Re: PHP5 Class problem

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

 



Thomas Munz wrote:
I'm using PHP 5.0.3 and if a problem if a class method. I'm initializing a class like that:

$o_SessionHandler = new SessionHandler();
var_dump($o_SessionHandler->getOrgSession());exit;


...

     //-- returns the original login
     static public function getOrgSession()
     {
          //-- return var
          return $this->a_session_org;
     }
}


The getOrgSession() function is inside of a class so the $this should be avaible...

$this is defined only if the following 2 things are true.

1. you are calling the method on a object
(i.e. not as a static call like SessionHandler::getOrgSession())

2. the function (method) you are calling is _NOT_ defined as static.

in your case you have defined all your methods as static.... so the
engine will not make $this available even if you call the method/function
on an instantiated object.

solution - remove 'static' from the function definitions that you wish
to use $this in.


any ideas? thanks!


-- 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