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

Documenting Parameters

<?php

// what does 1 and true mean here?
$keys = array_keys($array, 1, true);

// yes but of course
$keys = array_keys($array, filter_value:1, strict:true);

?>

Sometimes, even a literal value used as parameter is not readable. An easy way to document the literal values is to provide the name of the parameter. Since the parameters need a smart name to be used in the method, using it in the method call provides more context to the parameter.

Another option is to make that literal value a constant, and use that constant to provide a readable name.

See Also

PHP Features

Last updated: 09 November 2026