Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

instance

An instance is an object of a class. The class provides the definitions of the behavior of that object, while the object holds the specific data, that makes it unique and distinguishable.

The creation of an instance, called instantiation, or to instantiate, is done with the new keyword.

<?php

    class Elephpant {
        private int $property;

        function __construct(int $arg) {
            $this->propety = $arg;
        }
    }

    $object = new Elephpant(2);

?>

Documentation

See Also