How can HTTP authentication be implemented using PHP without prompting the user for credentials?

HTTP authentication can be implemented in PHP without prompting the user for credentials by using the `$_SERVER['PHP_AUTH_USER']` and `$_SERVER['PHP_AUTH_PW']` variables to access the username and password provided by the client in the HTTP header. This allows the server to authenticate the user without displaying a browser prompt for credentials.

if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
    header('WWW-Authenticate: Basic realm="My Realm"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Authorization Required';
    exit;
} else {
    $username = $_SERVER['PHP_AUTH_USER'];
    $password = $_SERVER['PHP_AUTH_PW'];

    // Validate username and password against database or other authentication method
}