Method
ServerRequest::getAttribute
Retrieve a single derived request attribute.
Description#
public ServerRequest::getAttribute(
$name,
$default = null
)Retrieves a single derived request attribute as described in getAttributes(). If the attribute has not been previously set, returns the default value as provided.
This method obviates the need for a hasAttribute() method, as it allows specifying a default value to return if the attribute is not found.
Parameters#
- $name
- The attribute name.
- $default = null
- Default value to return if the attribute does not exist.
See also#
ServerRequest::getAttributesRetrieve attributes derived from the request.