Jump to content

Why use interfaces in PHP (OOP)


dpacmittal

Recommended Posts

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

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.