Source Code:
(back to article)
<?php // Example 1 interface MyInterface { public function someMethod(); } class MyClass implements MyInterface { public function someMethod() { echo "This is from someMethod." . PHP_EOL; } } $obj = new MyClass(); $obj->someMethod(); // Output: This is from someMethod. // Example 2 interface MyOtherInterface { public function someOtherMethod(); } class MyOtherClass implements MyInterface, MyOtherInterface { public function someMethod() { echo "This is from someMethod."; } public function someOtherMethod() { echo "This is from someOtherMethod."; } } $obj2 = new MyOtherClass(); $obj2->someMethod(); $obj2->someOtherMethod(); // Output: This is from someMethod. This is from someOtherMethod.
Result:
Report an issue