CONTENT TYPE
<?php
+
+function dump($ctr) {
+ print_r(array_map(function($v){return round($v,2);}, $ctr));
+}
+
$ct = http\Env::negotiateContentType(array("text/html","text/xml","text/json"), $ctr);
-echo "$ct: "; print_r($ctr);
+echo "$ct: "; dump($ctr);
$ct = http\Env::negotiateContentType(array("text/xml","text/json"), $ctr);
-echo "$ct: "; print_r($ctr);
+echo "$ct: "; dump($ctr);
$ct = http\Env::negotiateContentType(array("text/json"), $ctr);
-echo "$ct: "; print_r($ctr);
+echo "$ct: "; dump($ctr);
?>
CHARSET
<?php
$cs = http\Env::negotiateCharset(array("utf-8", "iso-8859-1", "iso-8859-15"), $csr);
-echo "$cs: "; print_r($csr);
+echo "$cs: "; dump($csr);
$cs = http\Env::negotiateCharset(array("iso-8859-1", "iso-8859-15"), $csr);
-echo "$cs: "; print_r($csr);
+echo "$cs: "; dump($csr);
$cs = http\Env::negotiateCharset(array("utf-16", "iso-8859-15", "iso-8859-2"), $csr);
-echo "$cs: "; print_r($csr);
+echo "$cs: "; dump($csr);
?>
ENCODING
<?php
$ce = http\Env::negotiateEncoding(array("gzip", "deflate", "sdch"), $cer);
-echo "$ce: "; print_r($cer);
+echo "$ce: "; dump($cer);
$ce = http\Env::negotiateEncoding(array("", "sdch"), $cer);
-echo "$ce: "; print_r($cer);
+echo "$ce: "; dump($cer);
?>
LANGUAGE
<?php
$ln = http\Env::negotiateLanguage(array("de", "en", "fr"), $lnr);
-echo "$ln: "; print_r($lnr);
+echo "$ln: "; dump($lnr);
$ln = http\Env::negotiateLanguage(array("de-DE", "de-AT", "en"), $lnr);
-echo "$ln: "; print_r($lnr);
+echo "$ln: "; dump($lnr);
$ln = http\Env::negotiateLanguage(array("nl", "fr", "en"), $lnr);
-echo "$ln: "; print_r($lnr);
+echo "$ln: "; dump($lnr);
?>
CUSTOM
<?php
$cc = http\Env::negotiate("a, a.b;q=0.9, c.d;q=0, *.* ; q=0.1",
array("a.x", "c.d", "c.e", "a.b"), ".", $ccr);
-echo "$cc: "; print_r($ccr);
+echo "$cc: "; dump($ccr);
?>
DONE
--EXPECT--
de: Array
(
- [de] => 0.99
+ [de] => 0.97
[en] => 0.8
)
de-DE: Array
a.b: Array
(
[a.b] => 0.9
- [c.e] => 0.1
- [a.x] => 0.1
+ [c.e] => 0.08
+ [a.x] => 0.08
)
DONE