© Mikael Olsson 2016

Mikael Olsson, PHP 7 Quick Scripting Reference, 10.1007/978-1-4842-1922-5_14

14. Interface

Mikael Olsson

(1)Hammarland, Finland

An interface specifies methods that classes using the interface must implement. They are defined with the interface keyword, followed by a name and a code block . Their naming convention is to start with a small i and then to have each word initially capitalized.

interface iMyInterface {}

Interface Signatures

The code block for an interface can contain signatures for instance methods. These methods cannot have any implementations. Instead, their bodies are replaced by semicolons. Interface methods must always be public.

interface iMyInterface{  public function myMethod();}

Additionally, interfaces may define ...

Get PHP 7 Quick Scripting Reference, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.