$user_agent = $_SERVER['HTTP_USER_AGENT']; echo "User-Agent: $user_agent";
$is_ajax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'; if ($is_ajax) { echo "This is an Ajax request"; } else { echo "This is not an Ajax request"; }This code checks if the `X-Requested-With` header is set and has a value of `XMLHttpRequest`. If it does, the request is an Ajax request. Package library: These examples did not utilize any particular package library, as they only use PHP's built-in `$_SERVER` variable. However, some popular PHP libraries for handling HTTP requests and responses include Guzzle and cURL, which provide more advanced functionality for working with headers.