1 # int http\Header\Parser::parse(string $data, int $flags, array &$message = NULL)
8 The (part of the) header to parse.
10 Any combination of [parser flags](http/Header/Parser#Parser.flags:).
11 * array &$header = NULL
12 Successfully parsed headers.
16 * int, http\Header\Parser::STATE_* constant.
20 * http\Exception\InvalidArgumentException
28 "Two: header\n\tlines\n",
29 "Three",": header\n lines\n here\n",
30 "More: than one header\n",
31 "More: ", "than: ", "you: ", "expect\n",
35 $states = [-1=>"FAILURE",0=>"START","KEY","VALUE","VALUE_EX","HEADER_DONE","DONE"];
36 $parser = new http\Header\Parser;
38 $state = $parser->parse($part = array_shift($headers),
39 $headers ? 0 : http\Header\Parser::CLEANUP,
41 printf("%2\$-32s | %1\$s\n", $states[$state], addcslashes($part, "\r\n\t\0"));
42 } while ($headers && $state !== http\Header\Parser::STATE_FAILURE);
53 Two: header\n\tlines\n | VALUE_EX
55 : header\n lines\n here\n | VALUE_EX
56 More: than one header\n | VALUE_EX
66 string(12) "header lines"
68 string(17) "header lines here"
72 string(15) "than one header"
74 string(17) "than: you: expect"