Classes
Introduction
Classes provide a way to group functionality and state together.
Defining a class
A class is defined using the class
keyword followed by the name of the class and a block of code.
class Example {
// ...
}
Instantiation
To create an instance of a class, use the new
keyword followed by the name of the class.
function main(): void {
$counter = new Example();
}
Refer to Expressions: Class Operations - Instantiation for more information.