Dhënia e statusit të përgjigjes HTTP në PHP
Mund të vendosni veçmas statusin e përgjigjes HTTP,
pa specifikuar rreshtin e fillimit.
Kjo bëhet duke përdorur funksionin
http_response_code:
<?php
http_response_code(404);
?>
Plotësoni kodin në mënyrë që të jepen statuset përkatëse HTTP:
<?php
$arr = ['a', 'b', 'c'];
if (isset($_GET['key'])) {
$key = $_GET['key'];
if (isset($arr[$key])) {
echo $arr[$key];
} else {
// jep 404
echo 'Not Found';
}
} else {
// jep 403
echo 'Forbidden';
}
?>