WordPress\AiClientDependencies\Psr\Http\Message

ServerRequestInterface::getAttributepublicWP 1.0

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.

Method of the class: ServerRequestInterface{}

No Hooks.

Returns

Mixed.

Usage

$ServerRequestInterface = new ServerRequestInterface();
$ServerRequestInterface->getAttribute( $name, $default );
$name(string) (required)
The attribute name.
$default(mixed)
Default value to return if the attribute does not exist.
Default: null

Notes

  • See: getAttributes()

ServerRequestInterface::getAttribute() code WP 7.0

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