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

      <tfoot id='hWJZK'></tfoot>

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

        使用带有参数的 file_get_contents 从 PHP 获取请求

        GET Request from PHP using file_get_contents with parameters(使用带有参数的 file_get_contents 从 PHP 获取请求)

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

                1. 本文介绍了使用带有参数的 file_get_contents 从 PHP 获取请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想向外部站点发送GET请求,但也想发送一些参数

                  I want to send a GET request to an external site, but also want to send some parameters

                  例如,我必须向 example.com 发送获取请求

                  for example i've to send a get request to example.com

                  我想执行 www.example.com/send.php?uid=1&pwd=2&msg=3&phone=3&provider=xyz

                  i want to execute www.example.com/send.php?uid=1&pwd=2&msg=3&phone=3&provider=xyz

                  我的代码是:

                  $getdata = http_build_query(
                  array(
                      'uid' => '1',
                      'pwd' => '2',
                   'msg'=>'3',
                   'phone'=>'9999',
                   'provider'=>'xyz'
                   )
                  );
                  
                  $opts = array('http' =>
                   array(
                      'method'  => 'GET',
                      'content' => $getdata
                  )
                  );
                  
                  $context  = stream_context_create($opts);
                  
                  $result = file_get_contents('http://example.com/send.php', false, $context);
                  

                  我收到服务器错误.

                  推荐答案

                  content 选项用于 POSTPUT 请求.对于 GET,您可以将其附加为查询字符串:

                  The content option is used with POST and PUT requests. For GET you can just append it as a query string:

                  file_get_contents('http://example.com/send.php?'.$getdata, false, $context);
                  

                  此外,method 默认为 GET,因此您甚至不需要设置选项,也不需要创建流上下文.因此,对于这种特殊情况,您可以根据需要简单地使用第一个参数调用 file_get_contents.

                  Furthermore, the method defaults to GET so you don't even need to set options, nor create a stream context. So, for this particular situation, you could simply call file_get_contents with the first parameter if you wish.

                  这篇关于使用带有参数的 file_get_contents 从 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='89oRT'><style id='89oRT'><dir id='89oRT'><q id='89oRT'></q></dir></style></legend>

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

                      • <tfoot id='89oRT'></tfoot>

                            <small id='89oRT'></small><noframes id='89oRT'>