Afgivelse af HTTP-svarstatus i PHP

Du kan indstille HTTP-svarstatus separat, uden at angive startlinjen. Dette gøres ved hjælp af funktionen http_response_code:

php<?php
  http_response_code(404);
?>
Задание 1

Udfyld koden, så de tilsvarende HTTP-statuskoder afgives:

php<?php
  $arr = ['a', 'b', 'c'];
  
  if (isset($_GET['key'])) {
    $key = $_GET['key'];
    
    if (isset($arr[$key])) {
      echo $arr[$key];
    } else {
      // afgiv 404
      echo 'Not Found';
    }
  } else {
    // afgiv 403
    echo 'Forbidden';
  }
?>