« 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 | 638 Comments »

January 14th, 2026 at 10:11
อ่านเพลินเลยครับ ขอบคุณครับ
Heere is my web blog; บุหรี่ terea
January 14th, 2026 at 10:23
สวัสดีจ้า เขียนได้ดีมากเลยครับ กำลังหาข้อมูลเกี่ยวกับ iqos อยู่พอดี เป็นกำลังใจให้นะครับ
Also visit my web-site; iqos terea
January 14th, 2026 at 10:46
ติดตามผลงานอยู่นะครับ
Have a look att my web-site – บุหรี่ terea ราคา
January 14th, 2026 at 11:32
สวัสดีครับ ชอบบทความนี้จัง อ่านแล้วได้ความรู้เรื่อง iqols
เพิ่มขึ้นเยอะเลย ขอบคุณที่แบ่งปันข้อมูลดีๆ ครับ
Also visit my blog post iqos bangkok
January 14th, 2026 at 12:04
สวัสดีครับ บทความนี้มีประโยชน์มาก ใครที่สนใจ iqos ต้องมาอ่านตรงนี้เลย ขอบคุณมากครับ
My page terea iqos
January 14th, 2026 at 14:16
อ่านเพลินเลยครับ
ขอบคุณครับ
my web site – terea บุหรี่ ซื้อ ที่ไหน
January 14th, 2026 at 14:17
ติดตามผลงานอยู่นะครับ
Stop by my website … บุหรี่terea
January 14th, 2026 at 14:34
สุดยอดเลยครับสำหรับบทความนี้
Here is my page; บุหรี่terea
January 14th, 2026 at 14:43
ขอบคุณสำหรับบทความดีๆ ครับ
Feel free to visit my webb blog terea iqos ราคาส่ง
January 14th, 2026 at 14:43
อ่านเพลินเลยครับ ขอบคุณครับ
Feel free to surf to my web bloig terea บุหรี่
January 14th, 2026 at 15:34
ทักทายครับ ชอบบทความนี้จัง ช่วยให้เข้าใจเรื่อง iqos มากขึ้น เป็นกำลังใจให้นะครับ
January 14th, 2026 at 15:37
ชอบบทความนี้มากครับ
Here is my web blog: บุหรี่terea
January 14th, 2026 at 15:59
บทความมีประโยชน์มากครับ
Feel free to visit my website: terea iqos
January 14th, 2026 at 16:01
บทความมีประโยชน์มากครับ
My blog terea บุหรี่
January 14th, 2026 at 16:05
สวัสดีครับ บทความนี้มีประโยชน์มาก ใครที่สนใจ iqo ต้องมาอ่านตรงนี้เลย จะรอติดตามบทความต่อไปนะครับ
Feeel free to surf to my homepage :: iqos terea
January 14th, 2026 at 16:07
สวัสดีจ้า ชอบบทความนี้จัง ใครที่สนใจ iqos ต้องมาอ่านตรงนี้เลย จะรอติดตามบทความต่อไปนะครับ
Feel free to visit my blog: iqos terea
January 14th, 2026 at 16:43
เขียนได้น่าสนใจมากครับ
my website: terea iqos ราคาส่ง
January 14th, 2026 at 16:43
ติดตามผลงานอยู่นะครับ
My blog – terea บุหรี่ ราคา
January 14th, 2026 at 16:57
ติดตามผลงานอยู่นะครับ
my homepage :: terea บุหรี่
January 14th, 2026 at 17:36
สุดยอดเลยครับสำหรับบทความนี้
Here is my web-site … terea บุหรี่
January 14th, 2026 at 18:18
อ่านเพลินเลยครับ ขอบคุณครับ
Allso visit my web site :: terea ราคา
January 14th, 2026 at 18:35
บทความมีประโยชน์มากครับ
Heere is my web page – iqos terea
January 14th, 2026 at 19:29
ชอบบทความนี้มากครับ
Also visit my website: terea บุหรี่
January 14th, 2026 at 19:55
ชอบบทความนี้มากครับ
Also visit my web blog; บุหรี่ terea
January 14th, 2026 at 20:47
ติดตามผลงานอยู่นะครับ
Here is my webpage – terea ราคา
January 14th, 2026 at 21:05
สวัสดีครับ บทความนี้มีประโยชน์มาก กำลังหาข้อมูลเกี่ยวกับ iqoss
อยู่พอดี ขอบคุณมากครับ
Loook at my page discuss
January 15th, 2026 at 04:29
ขอบคุณสำหรับบทความดีๆ ครับ
Here is myy page: บุหรี่terea
January 15th, 2026 at 04:32
ชอบบทความนี้มากครับ
Here is my web page บุหรี่ terea ราคา
January 15th, 2026 at 04:58
เขียนได้น่าสนใจมากครับ
my web blog: terea iqos ราคา
January 15th, 2026 at 05:12
ติดตามผลงานอยู่นะครับ
My page: บุหรี่ terea
January 15th, 2026 at 05:39
สุดยอดเลยครับสำหรับบทความนี้
my page – terea iqos
January 15th, 2026 at 05:48
เนื้อหาแน่นมาก ขอบคุณที่แชร์
Here is my website; terea บุหรี่ ราคา
January 15th, 2026 at 13:55
เป็นข้อมูลที่ดีมากครับ
Here is myy homepage: terea iqos ราคาส่ง
January 15th, 2026 at 21:43
บทความนี้มีประโยชน์สำหรับผู้ที่สนใจซื้อรังนกและต้องการทราบราคารังนกแท้
พร้อมข้อมูลรังนกดิบและรังนกพร้อมดื่ม
January 17th, 2026 at 08:18
เป็นข้อมูลที่ดีมากครับ
Feel free too visit my webpage … บุหรี่ terea
January 17th, 2026 at 08:34
ติดตามผลงานอยู่นะครับ
my wrbsite บุหรี่ terea ราคา
January 17th, 2026 at 08:40
เขียนได้น่าสนใจมากครับ
Stop by my blog post terea iqos
January 17th, 2026 at 08:42
อ่านเพลินเลยครับ ขอบคุณครับ
Also visit my web page; บุหรี่ terea ราคา