2.1.0
[mdref/mdref-http] / http / Params.md
1 # class http\Params implements ArrayAccess
2
3 Parse, interpret and compose HTTP (header) parameters.
4
5 ## Changelog:
6
7 Version | Change
8 --------|-------
9 2.0.1 | Added [RFC5987](http://tools.ietf.org/html/rfc5987) support
10
11 ## Example:
12
13 <?php
14
15 $u = urlencode("ü");
16 $s = urlencode("ß");
17
18 $t = "p1*=utf-8'de's$u$s,p2*=utf-8''hei$s;a1*=utf-8''a$s;a2*=utf-8''e$s;a3=no,p3=not";
19 $p = new http\Params($t);
20
21 var_dump($p->params, $p->toString());
22
23 ?>
24
25 Yields:
26
27 array(3) {
28 ["p1"]=>
29 array(2) {
30 ["*rfc5987*"]=>
31 array(1) {
32 ["de"]=>
33 string(5) "süß"
34 }
35 ["arguments"]=>
36 array(0) {
37 }
38 }
39 ["p2"]=>
40 array(2) {
41 ["*rfc5987*"]=>
42 array(1) {
43 [""]=>
44 string(5) "heiß"
45 }
46 ["arguments"]=>
47 array(2) {
48 ["*rfc5987*"]=>
49 array(2) {
50 ["a1"]=>
51 array(1) {
52 [""]=>
53 string(3) "aß"
54 }
55 ["a2"]=>
56 array(1) {
57 [""]=>
58 string(3) "eß"
59 }
60 }
61 ["a3"]=>
62 string(2) "no"
63 }
64 }
65 ["p3"]=>
66 array(2) {
67 ["value"]=>
68 string(3) "not"
69 ["arguments"]=>
70 array(0) {
71 }
72 }
73 }
74 string(98) "p1*=utf-8'de's%C3%BC%C3%9F,p2*=utf-8''hei%C3%9F;a1*=utf-8''a%C3%9F;a2*=utf-8''e%C3%9F;a3=no,p3=not"
75
76
77 ## Constants:
78
79 * DEF_PARAM_SEP
80 The default parameter separator (",").
81 * DEF_ARG_SEP
82 The default argument separator (";").
83 * DEF_VAL_SEP
84 The default value separator ("=").
85 * COOKIE_PARAM_SEP
86 Empty param separator to parse cookies.
87 * PARSE_RAW
88 Do not interpret the parsed parameters.
89 * PARSE_DEFAULT
90 Interpret input as default formatted parameters.
91 * PARSE_URLENCODED
92 Urldecode single units of parameters, arguments and values.
93 * PARSE_DIMENSION
94 Parse sub dimensions indicated by square brackets.
95 * PARSE_QUERY
96 Parse URL querystring (same as http\Params::PARSE_URLENCODED|http\Params::PARSE_DIMENSION).
97 * PARSE_RFC5987
98 Parse [RFC5987](http://tools.ietf.org/html/rfc5987) style encoded character set and language information embedded in HTTP header params.
99
100 ## Properties:
101
102 * public $params = NULL
103 The (parsed) parameters.
104 * public $param_sep = http\Params::DEF_PARAM_SEP
105 The parameter separator(s).
106 * public $arg_sep = http\Params::DEF_ARG_SEP
107 The argument separator(s).
108 * public $val_sep = http\Params::DEF_VAL_SEP
109 The value separator(s).
110 * public $flags = http\Params::PARSE_DEFAULT
111 The modus operandi of the parser. See http\Params::PARSE_* constants.