Skip to content
On this page



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 {
    // ...


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.

Licensed under either of the MIT License or the Apache License (Version 2.0), at your option.