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

Special Types

PHP defines some special types.

  • mixed: any type
  • void: no returned value
  • callable: may be used as a callback
  • iterable: may be used with foreach(), including array
  • never: never returns
  • object: object of any class
  • parent: any of the parent class of the current class, excluding it
  • self: the current class
  • static: the current called class

Other special types are the scalar types.

<?php

    function trumpet(iterable $herd) : never {
        foreach ($herd as $calf) {
            echo $calf;
        }

        die();
    }

?>

Documentation

See Also