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

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

      1. <small id='j1iAx'></small><noframes id='j1iAx'>

        <tfoot id='j1iAx'></tfoot>

        PHP get_headers() 替代

        PHP get_headers() alternative(PHP get_headers() 替代)

        <tfoot id='bTUGB'></tfoot>
            <tbody id='bTUGB'></tbody>
                • <bdo id='bTUGB'></bdo><ul id='bTUGB'></ul>

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

                • <legend id='bTUGB'><style id='bTUGB'><dir id='bTUGB'><q id='bTUGB'></q></dir></style></legend>
                  本文介绍了PHP get_headers() 替代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要一个 PHP 脚本来读取每个 URL 请求的 HTTP 响应代码.

                  I need a PHP script that reads the HTTP response code for each URL request.

                  类似

                  $headers = get_headers($theURL);
                  return substr($headers[0], 9, 3);
                  

                  问题是 get_headers() 函数在服务器级别被禁用,作为一项策略.所以它不起作用.

                  The problem is the get_headers() function is disabled at server level, as a policy.So it doesn't work.

                  问题是如何获取 URL 的 HTTP 响应代码?

                  The question is how to get the HTTP response code for a URL?

                  推荐答案

                  如果启用了 cURL,您可以使用它来获取整个标头或仅获取响应代码.以下代码将响应代码分配给 $response_code 变量:

                  If cURL is enabled, you can use it to get the whole header or just the response code. The following code assigns the response code to the $response_code variable:

                  $curl = curl_init();
                  curl_setopt_array( $curl, array(
                      CURLOPT_RETURNTRANSFER => true,
                      CURLOPT_URL => 'http://stackoverflow.com' ) );
                  curl_exec( $curl );
                  $response_code = curl_getinfo( $curl, CURLINFO_HTTP_CODE );
                  curl_close( $curl );
                  

                  要获取整个标头,您可以发出 HEAD 请求,如下所示:

                  To get the whole header you can issue a HEAD request, like this:

                  $curl = curl_init();
                  curl_setopt_array( $curl, array(
                      CURLOPT_HEADER => true,
                      CURLOPT_NOBODY => true,
                      CURLOPT_RETURNTRANSFER => true,
                      CURLOPT_URL => 'http://stackoverflow.com' ) );
                  $headers = explode( "
                  ", curl_exec( $curl ) );
                  curl_close( $curl );
                  

                  这篇关于PHP get_headers() 替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)

                • <small id='ysxv1'></small><noframes id='ysxv1'>

                    <tfoot id='ysxv1'></tfoot>

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

                          • <legend id='ysxv1'><style id='ysxv1'><dir id='ysxv1'><q id='ysxv1'></q></dir></style></legend>