How can a PHP script access incoming HTTP headers sent from a Java program?

To access incoming HTTP headers sent from a Java program in a PHP script, you can use the $_SERVER superglobal array in PHP. The headers sent from the Java program will be available in this array under keys prefixed with 'HTTP_'.

// Access incoming HTTP headers sent from a Java program
$headers = [];
foreach ($_SERVER as $key => $value) {
    if (strpos($key, 'HTTP_') === 0) {
        $headers[str_replace('HTTP_', '', $key)] = $value;
    }
}

// Print out the headers
print_r($headers);