Skip to content

ServerRequest: withAttribute Example

Terry L edited this page Jun 20, 2020 · 3 revisions

Shieldon\Psr7\ServerRequest

Extends Request.

withAttribute($name, $value)

Return an instance with the specified derived request attribute.

  • param string name * The attribute name.
  • param mixed value * The value of the attribute.
  • return static

Example:

$serverRequest = $serverRequest->withAttribute('ip_address', '19.89.6.4');
$ip = $serverRequest->getAttribute('ip_address');

echo $ip
// Outputs: 19.89.6.4
Clone this wiki locally