Setting HTTP Headers via CURL in PHP

Using the option CURLOPT_HTTPHEADER you can send HTTP request headers when making a request. This option accepts an array of headers and their values as a parameter.

Let's set this option by passing some headers:

curl.php<?php
  $headers = [
    'Accept-Language: en-US',
    'Accept: text/html'
  ];
  
  curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
?>

On the page to which we are sending the request, you can check that the specified headers were sent:

file.php<?php
  var_dump($_SERVER['HTTP_ACCEPT_LANGUAGE']);
  var_dump($_SERVER['HTTP_ACCEPT']);
?>
Задание 1

Send a request to the following page, specifying the X-Test header:

file.php<?php
  echo $_SERVER['HTTP_X_TEST'];
?>
Задание 2

Send a request to the following page and get the result:

file.php<?php
  if ($_SERVER['HTTP_X_TEST'] === '12345') {
    echo 'result';
  } else {
    echo 'error';
  }
?>