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

Definition

A definition is the description of a particular constant, function, method, property, class, trait, interface or enum.

A variable also has a definition, also called an initialisation: variables have no formal definition. They use an unconditional assignation to do so.

The definition is also called a declaration. The declaration must happen before usage.

Definitions happens in custom code, in libraries or in extensions.

There are functions dedicated to listing defined elements: get_declared_constants(), get_declared_traits(), get_declared_interfaces(), get_declared_classes(), get_class_vars() and get_class_methods().

<?php

    //function declaration
    function trumpet() {
        print 'OK';
    }

    // call to the function trumpet
    trumpet();

?>

Documentation

See Also