PHP/interface
< PHP
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
About
In PHP, an interface is a set of public method-functions which can be required in either of two circumstances:
- in the declaration of a class
- This works almost identically to declaring the interface's methods as abstract functions in a trait or parent class.
- the type of a function argument or return value
- Advantages over declaring the object as a class:
- narrows down (more closely specifies) the function's expectations of a passed or returned object
- does not tie the object to a specific class hierarchy
- Advantages over declaring the object as a class:
Functions
- interface_exists() returns TRUE if the interface has been declared in code that has executed.
Links
- official: interfaces