To set a custom referer (referrer) header in a cURL request in PHP, you can use the CURLOPT_REFERER option. Here's an example:
$url = 'http://example.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, 'http://customreferrer.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// Process the response
echo $response;
In this example, we set the CURLOPT_REFERER option to 'http://customreferrer.com', which will set the referrer header in the cURL request to the specified custom referrer. Replace 'http://customreferrer.com' with the desired referrer you want to set.
Note that the referrer header is an optional header, and it may not always be respected or used by the requested server.