Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ServerRequestInterface.php

function ServerRequestInterface::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

See also

getAttributes()

1 method overrides ServerRequestInterface::getAttribute()
ServerRequest::getAttribute in vendor/guzzlehttp/psr7/src/ServerRequest.php

File

vendor/psr/http-message/src/ServerRequestInterface.php, line 227

Class

ServerRequestInterface
Representation of an incoming, server-side HTTP request.

Namespace

Psr\Http\Message

Code

public function getAttribute(string $name, $default = null);

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal