Compdigitec Labs

« | Home | »

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:

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 | 668 Comments »

668 Responses to “Changing the user agent of PHP”

  1. terea iqos ราคา Says:
    January 19th, 2026 at 14:01

    เขียนได้น่าสนใจมากครับ

    Review my site – terea iqos ราคา

  2. iqos thailand Says:
    January 19th, 2026 at 14:07

    สวัสดีครับ ชอบบทความนี้จัง กำลังหาข้อมูลเกี่ยวกับ iqos อยู่พอดี ขอบคุณที่แบ่งปันข้อมูลดีๆ ครับ

    Feel free tto visit my site iqos thailand

  3. บุหรี่ terea ราคา Says:
    January 19th, 2026 at 14:09

    ขอบคุณสำหรับข้อมูลครับ

    Also visit my homepage :: บุหรี่ terea ราคา

  4. iqos bangkok Says:
    January 19th, 2026 at 14:16

    สวัสดีครับ ชอบบทความนี้จัง ใครที่สนใจ iqos ต้องมาอ่านตรงนี้เลย ขอบคุณที่แบ่งปันข้อมูลดีๆ ครับ

    Also visit my web blog: iqos bangkok

  5. iqos terea Says:
    January 19th, 2026 at 14:18

    สวัสดีครับ เนื้อหาแน่นปึ้ก อ่านแล้วได้ความรู้เรื่อง iqos เพิ่มขึ้นเยอะเลย จะรอติดตามบทความต่อไปนะครับ

    Alsso visit myy site; iqos terea

  6. terea บุหรี่ ซื้อ ที่ไหน Says:
    January 19th, 2026 at 14:21

    ติดตามผลงานอยู่นะครับ

    Feeel free to surf too my weebsite … terea บุหรี่ ซื้อ ที่ไหน

  7. iqos thailand Says:
    January 19th, 2026 at 14:32

    สวัสดีครับ บทความนี้มีประโยชน์มาก
    กำลังหาข้อมูลเกี่ยวกับ iqos อยู่พอดี ขอบคุณมากครับ

    Also vvisit my web page – iqos thailand

  8. iqos iluma Says:
    January 19th, 2026 at 14:47

    ทักทายครับ บทความนี้มีประโยชน์มาก ใครที่สนใจ iqos ต้องมาอ่านตรงนี้เลย เป็นกำลังใจให้นะครับ

    Feel free to surf to my webpage: iqos iluma

  9. iqos thailand Says:
    January 19th, 2026 at 16:58

    สวัสดีจ้า เนื้อหาแน่นปึ้ก ช่วยให้เข้าใจเรื่อง iqos มากขึ้น จะรอติดตามบทความต่อไปนะครับ

    My site iqos thailand

  10. iqos bangkok Says:
    January 19th, 2026 at 17:00

    สวัสดีครับ ชอบบทความนี้จัง ช่วยให้เข้าใจเรื่อง iqos มากขึ้น จะรอติดตามบทความต่อไปนะครับ

    Feel fre to visit my homepage – iqos bangkok

  11. iqos thailand Says:
    January 19th, 2026 at 17:06

    สวัสดีครับ เนื้อหาแน่นปึ้ก ช่วยให้เข้าใจเรื่อง ios มากขึ้น ขอบคุณมากครับ

    Stop by my web-site … iqos thailand

  12. iqos iluma Says:
    January 19th, 2026 at 17:33

    สวัสดีครับ เขียนได้ดีมากเลยครับ กำลังหาข้อมูลเกี่ยวกับ
    iqos อยู่พอดี เป็นกำลังใจให้นะครับ

    My blog post :: iqos iluma

  13. iqos terea Says:
    January 19th, 2026 at 17:35

    ทักทายครับ เขียนได้ดีมากเลยครับ อ่านแล้วได้ความรู้เรื่อง iqos เพิ่มขึ้นเยอะเลย ขอบคุณมากครับ

    Here is mmy homepage … iqos terea

  14. iqos bangkok Says:
    January 19th, 2026 at 17:38

    สวัสดีจ้า เนื้อหาแน่นปึ้ก ใครที่สนใจ iqos ต้องมาอ่านตรงนี้เลย
    จะรอติดตามบทความต่อไปนะครับ

    Also visit my webpage … iqos bangkok

  15. iqos bangkok Says:
    January 19th, 2026 at 18:01

    สวัสดีครับ บทความนี้มีประโยชน์มาก ใครที่สนใจ iqos ต้องมาอ่านตรงนี้เลย จะรอติดตามบทความต่อไปนะครับ

    my webpage – iqos bangkok

  16. iqos Says:
    January 19th, 2026 at 18:03

    สวัสดีครับ บทความนี้มีประโยชน์มาก ใครที่สนใจ iqos ต้องมาอ่านตรงนี้เลย เป็นกำลังใจให้นะครับ

  17. iqos iluma Says:
    January 19th, 2026 at 18:33

    ทักทายครับ เขียนได้ดีมากเลยครับ ช่วยให้เข้าใจเรื่อง iqos มากขึ้น จะรอติดตามบทความต่อไปนะครับ

    Feel free to visit my blog pos :: iqos iluma

  18. iqos iluma Says:
    January 19th, 2026 at 18:43

    สวัสดีจ้า เขียนได้ดีมากเลยครับ ใครที่สนใจ iqos
    ต้องมาอ่านตรงนี้เลย เป็นกำลังใจให้นะครับ

    Feel free to isit my site … iqos iluma

Comments