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? 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. 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? 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. 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
Archived
This topic is now archived and is closed to further replies.