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

Use Alias

The use operator can create aliases for a class, function or constant. After the declaration of the alias, it is possible to use the original class with the alias name.

With PHP fallback mechanism, it is possible to declare locally a function with the name of a native PHP function. This is useful to mock such functions.

<?php

use Elephpant as Pachyderm;
use const HABITAT as ENCLOSURE;
use function trumpet as strtlower; // very confusing


class Elephpant {}

new Elephpant;
new Pachyderm;

?>

Documentation

See Also