0

What exactly is PHO OOP interface useful for?

I really don't understand what an interface does. The interface doesn't give any functionality to its methods, and depends on the object to define the function. If I have a class "myClass" and an object $object, I could just as easily add a new method to the object like $object->myMethod = function myFunc(); Why would I go through the trouble of first getting myClass to implement myInterface, and then define the method that way? Could someone show me an example where an interface comes in handy?

20th Aug 2019, 8:29 PM
Daryl
Daryl - avatar
1 Antwort
0
in team work every body called a name for every function and property. so when another programmer want to use every class, so he/she confused... interface can set a protocol for team to make clear functions and properties names...
3rd Sep 2020, 7:12 PM
Amin Maleki
Amin Maleki - avatar