【问题标题】:how to set user agent for get_headers PHP function如何为 get_headers PHP 函数设置用户代理
【发布时间】:2012-01-14 05:43:55
【问题描述】:

我知道为 curl 设置用户代理很容易,但我的代码基于 get_headers,默认情况下 get_headers 用户代理为空。 感谢您的帮助。

【问题讨论】:

    标签: php curl user-agent get-headers


    【解决方案1】:

    也许是这个?

    ini_set('user_agent', 'Mozilla/5.0');
    

    【讨论】:

      【解决方案2】:

      get_headers 只指定 server 发送给 client 的数据(本例中为 PHP),不指定请求头。

      如果您尝试查找发出 get_headers 请求的用户代理,则必须使用:

      ini_get('user_agent');
      

      有关更多文档,请参阅以下链接:

      【讨论】:

        猜你喜欢
        • 2011-08-30
        • 2011-08-28
        • 1970-01-01
        • 2017-11-27
        • 1970-01-01
        • 1970-01-01
        • 2013-01-25
        • 2010-12-05
        • 2021-01-26
        相关资源
        最近更新 更多