« Compiling re2c 0.13.5 on Ubuntu 8.04+ (binaries available) | Home | Manipulating symbolic and hard links on Linux and Windows »
Changing the user agent of PHP
By admin | August 20, 2008
If you ever need to adjust or change the default user agent that PHP accesses pages with (http and ftp wrappers) because either the default PHP user agent was blocked (“PHP”) or you wrote a bot with PHP and wish to customize it, you can do so easily with a php directive called “user_agent”. Note that 3rd party ways (such as cURL) are not affected by this setting.
To set it, you can use the following function:
<?php
function set_php_user_agent($useragent = ‘PHP’) {
$u = strval($useragent);
if(ini_set(‘user_agent’,$u) === false) {
$r = false;
} else {
$r = true;
}
return $r;
}
// Example:
set_php_user_agent(‘TestAgent/1.0 (http://www.example.com/testagent/)’);
?>
To get you started, here are some user agents for you to use or test:
- Mozilla/2.01 (Win16; I) – Netscape 2 on Windows 3.1
- Mozilla/2.0 (compatible; MSIE 3.0; I; Win95) – IE 3 on Windows 95
- Mozilla/3.0 (WinNT4; I) – Netspace 3 on Windows NT4
- Mozilla/4.0 (compatible; MSIE 4.01; Win98) – MSIE 4.01 on Windows 98
- Opera/5.11 (compatible; MSIE 5.0; Windows ME) [en] – Opera 5.11 on Windows ME
- Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322) – IE6 on WinXP
- Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0 (ubuntu-hardy) – Firefox 3.0 on Ubuntu Hardy
- Lynx/2.8.6rel.4 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/2.0.4 (Linux i686) – Lynx 2.8.6 on Linux
- Mozilla/5.0 Galeon/1.0.2 (X11; Linux i686; U;) Gecko/20011224 – Galeon 1.0.2 on Linux
- Lynx/2.8.6rel.4 (Windows NT 5.1; I) – Lynx 2.8.6 on Windows XP
- Wget/1.10.2 – GNU Wget 1.10.2
If you found this article interesting or helpful, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more interesting articles!
If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!
Topics: Internet, PHP | 65 Comments »

October 6th, 2025 at 15:06
ขอบคุณสำหรับบทความดี ๆ เกี่ยวกับงานศพ
พวงหรีดเป็นสัญลักษณ์ของการไว้อาลัยที่มีความหมายมาก
ดิฉันเคยใช้บริการร้านพวงหรีดจัดส่งถึงวัด ซึ่งทั้งสะดวกและตรงเวลา
แนะนำสำหรับใครที่กำลังมองหาพวงหรีดครับ
Also visit my site Boonforal
October 6th, 2025 at 20:02
บทความนี้ให้ข้อมูลน่าสนใจเกี่ยวกับการแสดงความเคารพผู้ล่วงลับ
พวงหรีดที่เหมาะสมช่วยแสดงความอาลัยได้อย่างสุภาพ
ผมเคยใช้บริการพวงหรีดออนไลน์ ซึ่งทั้งสะดวกและตรงเวลา
แนะนำสำหรับใครที่กำลังมองหาพวงหรีดครับ
Also visit my web ste – ดอกไม้งานศพ
October 7th, 2025 at 03:12
ขอบคุณสำหรับบทความดี ๆ เกี่ยวกับการไว้อาลัย
พวงหรีดเป็นสัญลักษณ์ของการไว้อาลัยที่มีความหมายมาก
ผมเคยใช้บริการพวงหรีดออนไลน์ ซึ่งทั้งสะดวกและตรงเวลา
แนะนำสำหรับใครที่กำลังมองหาร้านพวงหรีดคุณภาพครับ
Feeel free to visit my web page ดอกไม้งานศพ
October 7th, 2025 at 07:00
บทความนี้ให้ข้อมูลมีประโยชน์มากครับ ถ้าใครกำลังมองหาร้านจัดดอกไม้งานศพ ผมแนะนำลองดูร้านที่มีผลงานจริงและรีวิวดี ๆ ครับ
Here is my web-site … จัดดอกไม้งานพิธี
October 7th, 2025 at 15:02
ชอบแนวคิดที่แชร์ไว้ในบทความนี้ครับ ถ้าใครกำลังมองหาผู้ให้บริการตกแต่งงานศพ ผมแนะนำลองดูร้านที่มีผลงานจริงและรีวิวดี ๆ ครับ
Feeel free to surf to my page … noobgalore.us
October 8th, 2025 at 06:10
บทความนี้ให้ข้อมูลมีประโยชน์มากครับ ถ้าใครกำลังมองหาผู้ให้บริการตกแต่งงานศพ ผมแนะนำลองดูร้านที่มีผลงานจริงและรีวิวดี ๆ ครับ
My web blog Olivia
October 8th, 2025 at 07:35
ขอบคุณสำหรับบทความดี ๆ ครับ ถ้าใครกำลังมองหาผู้ให้บริการตกแต่งงานศพ ผมแนะนำลองดูร้านที่มีผลงานจริงและรีวิวดี ๆ ครับ
Visit my homepage :: รับจัดดอกไม้หน้าศพ
October 8th, 2025 at 10:05
ขอบคุณสำหรับบทความดี ๆ ครับ
ถ้าใครกำลังมองหาบริการจัดดอกไม้งานศพ ผมแนะนำลองดูร้านที่มีผลงานจริงและรีวิวดี
ๆ ครับ
October 8th, 2025 at 13:00
ขอบคุณสำหรับบทความดี ๆ
ครับ ถ้าใครกำลังมองหาบริการจัดดอกไม้งานศพ ผมแนะนำลองดูร้านที่มีผลงานจริงและรีวิวดี ๆ ครับ
Feel free to surf to my page … Olivia
October 8th, 2025 at 21:30
… [Trackback]
[…] Find More on on that Topic: compdigitec.com/labs/2008/08/20/changing-the-user-agent-of-php/ […]
October 13th, 2025 at 20:41
บทความนี้ให้ข้อมูลมีประโยชน์มากเกี่ยวกับการแสดงความเคารพผู้ล่วงลับ
การเลือกพวงหรีดพัดลมถือเป็นเรื่องสำคัญ
ดิฉันเคยใช้บริการพวงหรีดออนไลน์ ซึ่งทั้งสะดวกและตรงเวลา
แนะนำสำหรับใครที่กำลังมองหาร้านพวงหรีดคุณภาพครับ
Alsso visit my page :: ดอกไม้งานศพ
October 15th, 2025 at 07:57
Can’t get enough of good glass of wine. Doesn’t matter if it’s dry or sweet, it’s the perfect way to relax.
Are there anyy wine lovers around? #WhiteWine
Feel free to visit my web-site :: แชมเปญ
October 15th, 2025 at 11:11
Can’t get enugh of goopd vintage wine. From a local vineyard or imported, it’s the perfecht way to relax.
Aree there any wine lpvers around?
Check out my web page ร้านขายไวน์
October 26th, 2025 at 13:30
ขอบคุณสำหรับบทความดี ๆ ครับ
ถ้าใครกำลังมองหาบริการจัดดอกไม้งานศพ ผมแนะนำลองดูร้านที่มีผลงานจริงและรีวิวดี
ๆ ครับ
Also visit my web-site Olivia
October 26th, 2025 at 17:57
ชอบแนวคิดที่แชร์ไว้ในบทความนี้ครับ ถ้าใครกำลังมองหาบริการจัดดอกไม้งานศพ ผมแนะนำลองดูร้านที่มีผลงานจริงและรีวิวดี ๆ ครับ