dpacmittal Posted November 29, 2009 Share Posted November 29, 2009 I am learning OOP in PHP and its been a pretty good learning experience so far. What I didn't understand at all is interfaces. I understand the implications of multiple inheritance, and interface is used just to solve that. But what's the use? If we have to define the function in derived class why use interface, why not directly declare and define it inside the derived class? Am I missing something or is it really useless? Quote Link to comment https://forums.phpfreaks.com/topic/183270-why-use-interfaces-in-php-oop/ Share on other sites More sharing options...
Alex Posted November 29, 2009 Share Posted November 29, 2009 As with many standards in programming (especially with OOP) interfaces aren't totally for you, they're for other programmers that might use your code. It's a good way to insure that an object will maintain certain methods. Quote Link to comment https://forums.phpfreaks.com/topic/183270-why-use-interfaces-in-php-oop/#findComment-967290 Share on other sites More sharing options...
dpacmittal Posted November 29, 2009 Author Share Posted November 29, 2009 As with many standards in programming (especially with OOP) interfaces aren't totally for you, they're for other programmers that might use your code. It's a good way to insure that an object will maintain certain methods. Not so important then, eh? Quote Link to comment https://forums.phpfreaks.com/topic/183270-why-use-interfaces-in-php-oop/#findComment-967336 Share on other sites More sharing options...
Alex Posted November 29, 2009 Share Posted November 29, 2009 Definitely not one of the most useful features in PHP, but it can come in handy sometimes, especially when you plan on distributing your code. Quote Link to comment https://forums.phpfreaks.com/topic/183270-why-use-interfaces-in-php-oop/#findComment-967341 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.