What are the potential pitfalls of sending the Authorization header using the header() function in PHP?

Sending the Authorization header using the header() function in PHP can lead to potential security risks, as it exposes sensitive information such as user credentials. To mitigate this risk, it is recommended to use a secure method of handling authorization, such as using PHP's built-in cURL functions to make HTTP requests with the Authorization header.

$url = 'https://api.example.com';
$token = 'Bearer your_access_token';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: ' . $token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

curl_close($ch);

// Process the response
echo $response;