mdref.json config
[mdref/mdref-http] / http / Message / getHeader.md
1 # mixed http\Message::getHeader(string $header[, string $into_class = NULL])
2
3 Retrieve a single header, optionally hydrated into a http\Header extending class.
4
5 ## Params:
6
7 * string $header
8 The header's name.
9 * Optional string $into_class = NULL
10 The name of a class extending http\Header.
11
12 ## Returns:
13
14 * mixed, the header value if $into_class is NULL.
15 * http\Header, descendant.
16
17 ## Warnings:
18
19 * If $into_class is specified but is not a descendant of http\Header.
20
21 ## Example:
22
23 <?php
24 class hdr extends http\Header {
25 function __construct($name, $value) {
26 var_dump($name, $value);
27 parent::__construct($name, $value);
28 }
29 }
30
31 $msg = new http\Message("Foo: bar");
32 $msg->getHeader("foo", "hdr");
33 ?>
34
35 Yields:
36
37 string(3) "foo"
38 string(3) "bar"