I've got an almost empty page that I need for a curl. The thing is that it is also accessible by a browser and looks weird.
Is it possible in PHP to detect if the request come from a browser or a curl ? So that way I can make a redirect if it comes from browser.
Thank you.
This will get you the client Agent, among other stuff. If your curl does not pretend to be something else, it should do.
foreach (getallheaders() as $name => $value) {
echo "$name: $value
";
}
or simpler: $_SERVER['HTTP_USER_AGENT']
gets you the user-agent (browser signatur) directly.
Browser sends User-Agent
header in request, if you don't setup User-Agent
in curl just check request for this header.