<i id='q2wZ3'><tr id='q2wZ3'><dt id='q2wZ3'><q id='q2wZ3'><span id='q2wZ3'><b id='q2wZ3'><form id='q2wZ3'><ins id='q2wZ3'></ins><ul id='q2wZ3'></ul><sub id='q2wZ3'></sub></form><legend id='q2wZ3'></legend><bdo id='q2wZ3'><pre id='q2wZ3'><center id='q2wZ3'></center></pre></bdo></b><th id='q2wZ3'></th></span></q></dt></tr></i><div id='q2wZ3'><tfoot id='q2wZ3'></tfoot><dl id='q2wZ3'><fieldset id='q2wZ3'></fieldset></dl></div>

    <small id='q2wZ3'></small><noframes id='q2wZ3'>

        <bdo id='q2wZ3'></bdo><ul id='q2wZ3'></ul>
      <tfoot id='q2wZ3'></tfoot>
    1. <legend id='q2wZ3'><style id='q2wZ3'><dir id='q2wZ3'><q id='q2wZ3'></q></dir></style></legend>
      1. PHP file_get_contents() 和设置请求标头

        PHP file_get_contents() and setting request headers(PHP file_get_contents() 和设置请求标头)

          <bdo id='Cr8x7'></bdo><ul id='Cr8x7'></ul>

            <small id='Cr8x7'></small><noframes id='Cr8x7'>

            <legend id='Cr8x7'><style id='Cr8x7'><dir id='Cr8x7'><q id='Cr8x7'></q></dir></style></legend>
            <i id='Cr8x7'><tr id='Cr8x7'><dt id='Cr8x7'><q id='Cr8x7'><span id='Cr8x7'><b id='Cr8x7'><form id='Cr8x7'><ins id='Cr8x7'></ins><ul id='Cr8x7'></ul><sub id='Cr8x7'></sub></form><legend id='Cr8x7'></legend><bdo id='Cr8x7'><pre id='Cr8x7'><center id='Cr8x7'></center></pre></bdo></b><th id='Cr8x7'></th></span></q></dt></tr></i><div id='Cr8x7'><tfoot id='Cr8x7'></tfoot><dl id='Cr8x7'><fieldset id='Cr8x7'></fieldset></dl></div>
                <tbody id='Cr8x7'></tbody>
            1. <tfoot id='Cr8x7'></tfoot>

                  本文介绍了PHP file_get_contents() 和设置请求标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用 PHP,是否可以使用 file_get_contents() 发送 HTTP 标头?

                  With PHP, is it possible to send HTTP headers with file_get_contents() ?

                  我知道您可以从 php.ini 文件中发送用户代理.但是,您也可以使用 file_get_contents() 发送其他信息,例如 HTTP_ACCEPTHTTP_ACCEPT_LANGUAGEHTTP_CONNECTION 吗?

                  I know you can send the user agent from your php.ini file. However, can you also send other information such as HTTP_ACCEPT, HTTP_ACCEPT_LANGUAGE, and HTTP_CONNECTION with file_get_contents() ?

                  或者是否有其他功能可以做到这一点?

                  Or is there another function that will accomplish this?

                  推荐答案

                  其实进一步阅读file_get_contents()函数:

                  // Create a stream
                  $opts = [
                      "http" => [
                          "method" => "GET",
                          "header" => "Accept-language: en
                  " .
                              "Cookie: foo=bar
                  "
                      ]
                  ];
                  
                  // DOCS: https://www.php.net/manual/en/function.stream-context-create.php
                  $context = stream_context_create($opts);
                  
                  // Open the file using the HTTP headers set above
                  // DOCS: https://www.php.net/manual/en/function.file-get-contents.php
                  $file = file_get_contents('http://www.example.com/', false, $context);
                  

                  您也许可以按照这种模式来实现您想要的,不过我还没有亲自测试过.(如果它不起作用,请随时查看我的其他答案)

                  You may be able to follow this pattern to achieve what you are seeking to, I haven't personally tested this though. (and if it doesn't work, feel free to check out my other answer)

                  这篇关于PHP file_get_contents() 和设置请求标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  smtp gmail server php mailer not working(smtp gmail服务器php邮件程序不工作)
                  Email goes in spam when I send it via others SMTP server(当我通过其他 SMTP 服务器发送电子邮件时,电子邮件进入垃圾邮件)

                  <small id='ZhjnE'></small><noframes id='ZhjnE'>

                    <bdo id='ZhjnE'></bdo><ul id='ZhjnE'></ul>
                  • <tfoot id='ZhjnE'></tfoot>

                        <i id='ZhjnE'><tr id='ZhjnE'><dt id='ZhjnE'><q id='ZhjnE'><span id='ZhjnE'><b id='ZhjnE'><form id='ZhjnE'><ins id='ZhjnE'></ins><ul id='ZhjnE'></ul><sub id='ZhjnE'></sub></form><legend id='ZhjnE'></legend><bdo id='ZhjnE'><pre id='ZhjnE'><center id='ZhjnE'></center></pre></bdo></b><th id='ZhjnE'></th></span></q></dt></tr></i><div id='ZhjnE'><tfoot id='ZhjnE'></tfoot><dl id='ZhjnE'><fieldset id='ZhjnE'></fieldset></dl></div>
                            <tbody id='ZhjnE'></tbody>

                            <legend id='ZhjnE'><style id='ZhjnE'><dir id='ZhjnE'><q id='ZhjnE'></q></dir></style></legend>