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

void cannot be used as a parameter type

Description

Void is a type, that can only be used with return type, on methods or functions. Here, void represents the absence of value: this is not possible for a property or an argument. The null value is then the closest possible type that can be assigned to a property, yet representing no value.

Example

<?php

  function foo(void $p) { }

?>

Alternatives

  • Use another type for the argument.
  • Remove the argument.
  • Use the null type.