For example, in cURL I can use curl_setopt($curlrequest, CURLOPT_USERAGENT, 'myuseragent');
in order to change the User-Agent
when I'm requesting the page specified in $curlrequest
.
But can I do something similar with readfile()
?
For example, in cURL I can use curl_setopt($curlrequest, CURLOPT_USERAGENT, 'myuseragent');
in order to change the User-Agent
when I'm requesting the page specified in $curlrequest
.
But can I do something similar with readfile()
?
Yes, you can set a
user_agent
property in yourphp.ini
config file or viaini_set()
at runtime.See http://php.net/manual/en/filesystem.configuration.php#ini.user-agent (via http://php.net/manual/en/wrappers.http.php)
Update
An example (as requested)
You can set the
user_agent
property in the php.ini config file, or use ini_set to change it without modifying the php.ini, so you can customize on a per-script basis.Also, one of the comments from this page says you can do something like this: