Skip to content

Message: hasHeader Example

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

Shieldon\Psr7\Message

hasHeader($name)

Checks if a header exists by the given case-insensitive name.

  • param string name * Case-insensitive header field name.
  • return bool

Example:

if ($message->hasHeader('user-agent')) {
    echo 'Header user-agent exists.';
} else {
    echo 'Header user-agent does not exist.';
}
// Outputs: Header user-agent exists.
Clone this wiki locally