Re: PHP5 Class problem

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

 



daniel@xxxxxxxxxxxxxxxx wrote:
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.




how odd, i have assumed having a class static you could still throw around

classes cannot be defined as static - defining them as abstract has the effect of being able to only use a given class statically (unless you subclass it and the subclass is not abstract).

variables inside it, or its only meant to stay in the one static method so

yes you can use variables - but not member variables because $this is not defined in functions that are declared static - bare in mind you can call a method statically even though its not marked as static (just be sure you don't reference $this).

sidenote: the php4 trick of overwriting $this does not work in PHP5.

executing it like

Class::staticMethod();

and

Class::otherStaticMethod() ?

I don't really understand what your asking.



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