alecks Posted July 18, 2008 Share Posted July 18, 2008 Just a bit confused as to how PHP handles static methods; my impression is that they cannot be accessed through an instance ($obj->staticMethod(), only using the scope res op (class::staticMethod(). Is this correct? Quote Link to comment https://forums.phpfreaks.com/topic/115352-static-methods/ Share on other sites More sharing options...
btherl Posted July 18, 2008 Share Posted July 18, 2008 The answer is here. So no that is not correct, static methods can be accessed through an instance. Quote Link to comment https://forums.phpfreaks.com/topic/115352-static-methods/#findComment-593074 Share on other sites More sharing options...
alecks Posted July 18, 2008 Author Share Posted July 18, 2008 Whats the point of having static methods then? Quote Link to comment https://forums.phpfreaks.com/topic/115352-static-methods/#findComment-593586 Share on other sites More sharing options...
KevinM1 Posted July 18, 2008 Share Posted July 18, 2008 Whats the point of having static methods then? Static methods are useful when you need some functionality, but don't need an object afterwards. Factories often use static methods because most people want the object created by the factory, not the factory itself. There was a larger conversation about this here: http://www.phpfreaks.com/forums/index.php/topic,206892.0.html Quote Link to comment https://forums.phpfreaks.com/topic/115352-static-methods/#findComment-593589 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.