How do you define an interface in PHP?
- interface InterfaceName
- trait InterfaceName
- class InterfaceName
- abstract class InterfaceName
In PHP, to define an interface, you use the interface keyword followed by the name of the interface. For example: interface InterfaceName { } An interface can contain method signatures without implementation, and it can also define constants. Interfaces establish a contract that classes must adhere to when implementing the interface. Classes that implement an interface must provide an implementation for all the methods defined in the interface. To learn more about interfaces in PHP, refer to: http://php.net/manual/en/language.oop5.interfaces.php
Loading...
Related Quiz
- How can we determine whether a PHP variable is an instantiated object of a certain class?
- You are writing a PHP script and you need to sanitize user input. How would you do this?
- How can we automatically escape incoming data?
- The ceil() function in PHP rounds a number up to the nearest ______.
- If the file to be included using the include statement in PHP is not found, the script will ______.