Practical Web Data Patterns
Header Labels
Turn a request header value into a simple label.
Header Labels
header_label.php
<?php
$accept = ;
$contentType = "text/plain";
if ($accept === "json") {
$contentType = "application/json";
} elseif ($accept === "html") {
$contentType = "text/html";
}
echo "accept=" . $accept . "\n";
echo "contentType=" . $contentType . "\n";
<?php
$accept = ;
$contentType = "text/plain";
if ($accept === "json") {
$contentType = "application/json";
} elseif ($accept === "html") {
$contentType = "text/html";
}
echo "accept=" . $accept . "\n";
echo "contentType=" . $contentType . "\n";
<?php
$accept = ;
$contentType = "text/plain";
if ($accept === "json") {
$contentType = "application/json";
} elseif ($accept === "html") {
$contentType = "text/html";
}
echo "accept=" . $accept . "\n";
echo "contentType=" . $contentType . "\n";
header-label
Request headers can influence response behavior, but static examples should model them with local scalar values.