It is easy to set the User-Agent header in PHP. You can either edit your PHP installation's php.ini file or add the following line of code to your PHP script. The cURL library also supports setting HTTP headers, but this library is not included in the standard PHP installation.
//tell it what value to use for the User-Agent header ini_set('user_agent', 'My Cool Screen-Scraper (+http://www.mangst.com)'); //includes the above User-Agent header in this request and all subsequent requests $page = file_get_contents('http://en.wikipedia.org/wiki/Pumpkin');
Note that this is different from the header() function. The header() function is used to set the headers of the HTTP response that the PHP script itself is generating. This has nothing to do with any HTTP requests that the script makes in the process of generating its response.