public function ServerRequest::getAttribute in Zircon Profile 8.0
Same name in this branch
- 8.0 vendor/zendframework/zend-diactoros/src/ServerRequest.php \Zend\Diactoros\ServerRequest::getAttribute()
- 8.0 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/ServerRequest.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\ServerRequest::getAttribute()
Same name and namespace in other branches
- 8 vendor/zendframework/zend-diactoros/src/ServerRequest.php \Zend\Diactoros\ServerRequest::getAttribute()
Retrieve a single derived request attribute.
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
string $name The attribute name.:
mixed $default Default value to return if the attribute does not exist.:
Return value
mixed
Overrides ServerRequestInterface::getAttribute
See also
getAttributes()
File
- vendor/
zendframework/ zend-diactoros/ src/ ServerRequest.php, line 182
Class
- ServerRequest
- Server-side HTTP request
Namespace
Zend\DiactorosCode
public function getAttribute($attribute, $default = null) {
if (!array_key_exists($attribute, $this->attributes)) {
return $default;
}
return $this->attributes[$attribute];
}