I am new to PHP, I am using Guzzle client to make a Rest Call and also adding request header using $_SERVER variable.
But in my request call, sometimes the user sends a Header(x-api-key) and sometimes there is no header. When a header is not sent in request my PHP Guzzle throws an error,
Notice: Undefined index: HTTP_X_API_KEY in Z:\xampp\htdocs\bb\index.php on line 16
<?php 
require './vendor/autoload.php';
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', 'http://s.com',[
    'headers' => [
        'User-Agent' => $_SERVER['HTTP_USER_AGENT'],
        'x-api-key' => $_SERVER['HTTP_X_API_KEY']   
    ]
]);
$json = $res->getBody();   
echo $json;
$manage = json_decode($json, true);
echo $manage;
?>
How can I make this x-api-key header optional and not triggering the PHP error.
 
    