• <legend id='ZyMER'><style id='ZyMER'><dir id='ZyMER'><q id='ZyMER'></q></dir></style></legend>
    1. <tfoot id='ZyMER'></tfoot>

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

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

        如何在 PHP 中读取任何请求标头

        How do I read any request header in PHP(如何在 PHP 中读取任何请求标头)

            <tbody id='4pevc'></tbody>
        • <small id='4pevc'></small><noframes id='4pevc'>

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

                <legend id='4pevc'><style id='4pevc'><dir id='4pevc'><q id='4pevc'></q></dir></style></legend>

                  <tfoot id='4pevc'></tfoot>
                  本文介绍了如何在 PHP 中读取任何请求标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我应该如何阅读 PHP 中的任何标头?

                  How should I read any header in PHP?

                  例如自定义标头:X-Requested-With.

                  推荐答案

                  IF:你只需要一个header,而不是all headers,最快的方法是:

                  IF: you only need a single header, instead of all headers, the quickest method is:

                  <?php
                  // Replace XXXXXX_XXXX with the name of the header you need in UPPERCASE (and with '-' replaced by '_')
                  $headerStringValue = $_SERVER['HTTP_XXXXXX_XXXX'];
                  


                  ELSE IF:您将 PHP 作为 Apache 模块运行,或者从 PHP 5.4 开始,使用 FastCGI(简单方法):


                  ELSE IF: you run PHP as an Apache module or, as of PHP 5.4, using FastCGI (simple method):

                  apache_request_headers()

                  <?php
                  $headers = apache_request_headers();
                  
                  foreach ($headers as $header => $value) {
                      echo "$header: $value <br />
                  ";
                  }
                  


                  ELSE: 在任何其他情况下,您都可以使用(用户态实现):


                  ELSE: In any other case, you can use (userland implementation):

                  <?php
                  function getRequestHeaders() {
                      $headers = array();
                      foreach($_SERVER as $key => $value) {
                          if (substr($key, 0, 5) <> 'HTTP_') {
                              continue;
                          }
                          $header = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))));
                          $headers[$header] = $value;
                      }
                      return $headers;
                  }
                  
                  $headers = getRequestHeaders();
                  
                  foreach ($headers as $header => $value) {
                      echo "$header: $value <br />
                  ";
                  }
                  


                  另请参阅:
                  getallheaders() - (PHP >= 5.4) 跨平台版本 apache_request_headers()的别名apache_response_headers() - 获取所有 HTTP 响应标头.
                  headers_list() - 获取要发送的标头列表.


                  See Also:
                  getallheaders() - (PHP >= 5.4) cross platform edition Alias of apache_request_headers() apache_response_headers() - Fetch all HTTP response headers.
                  headers_list() - Fetch a list of headers to be sent.

                  这篇关于如何在 PHP 中读取任何请求标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  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 的问题)
                  • <legend id='EuTV9'><style id='EuTV9'><dir id='EuTV9'><q id='EuTV9'></q></dir></style></legend>
                    <i id='EuTV9'><tr id='EuTV9'><dt id='EuTV9'><q id='EuTV9'><span id='EuTV9'><b id='EuTV9'><form id='EuTV9'><ins id='EuTV9'></ins><ul id='EuTV9'></ul><sub id='EuTV9'></sub></form><legend id='EuTV9'></legend><bdo id='EuTV9'><pre id='EuTV9'><center id='EuTV9'></center></pre></bdo></b><th id='EuTV9'></th></span></q></dt></tr></i><div id='EuTV9'><tfoot id='EuTV9'></tfoot><dl id='EuTV9'><fieldset id='EuTV9'></fieldset></dl></div>

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

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

                              <tbody id='EuTV9'></tbody>