You are here

public function MessageTrait::getHeaderLine in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-diactoros/src/MessageTrait.php \Zend\Diactoros\MessageTrait::getHeaderLine()
  2. 8 vendor/guzzlehttp/psr7/src/MessageTrait.php \GuzzleHttp\Psr7\MessageTrait::getHeaderLine()
Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-diactoros/src/MessageTrait.php \Zend\Diactoros\MessageTrait::getHeaderLine()

Retrieves a comma-separated string of the values for a single header.

This method returns all of the header values of the given case-insensitive header name as a string concatenated together using a comma.

NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating.

If the header does not appear in the message, this method MUST return an empty string.

Parameters

string $name Case-insensitive header field name.:

Return value

string A string of values as provided for the given header concatenated together using a comma. If the header does not appear in the message, this method MUST return an empty string.

File

vendor/zendframework/zend-diactoros/src/MessageTrait.php, line 163

Class

MessageTrait
Trait implementing the various methods defined in MessageInterface.

Namespace

Zend\Diactoros

Code

public function getHeaderLine($name) {
  $value = $this
    ->getHeader($name);
  if (empty($value)) {
    return '';
  }
  return implode(',', $value);
}