Penghantaran Status Respons HTTP dalam PHP

Anda boleh menetapkan status respons HTTP secara berasingan, tanpa menyatakan baris permulaan. Ini dilakukan menggunakan fungsi http_response_code:

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

Lengkapkan kod supaya status HTTP yang sepadan dihantar:

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