Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explicit interface implementation in php

Tags:

php

interface

Since I'm a C#-/.NET-guy, I'm used to explicit interface implementations - like so:

public interface IBar
{
    bool Bacon();
}

public class Foo : IBar
{
    bool IBar.Bacon() {}
}

Question:
Is this possible to do in php?

Edit:
To clarify, this is implicit (while what I want, and what is in the above example, is explicit):

public class Foo : IBar
{
    bool Bacon() {}
}
like image 417
Marcus Hansson Avatar asked Mar 09 '26 19:03

Marcus Hansson


1 Answers

PHP supports interfaces, so yes it is possible: http://php.net/manual/en/language.oop5.interfaces.php

PHP does not distinguish between implicit and explicit implementations.

like image 89
Jan Hančič Avatar answered Mar 11 '26 09:03

Jan Hančič



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!