简体   繁体   English

curl命令在php中打印查询字符串参数

[英]curl command to print query string parameters in php

Is there any command in php curl to print response query string parameters php curl中是否有任何命令可以打印响应查询字符串参数

Below is my php code 下面是我的PHP代码

      <?php
      session_start();

      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL,"http://192.168.1.220/cgi-bin/handle_login.tcl");
     curl_setopt($ch, CURLOPT_POST, TRUE);
     curl_setopt($ch, CURLOPT_POSTFIELDS,
        "user=admin&pw=admin&submit=Login&sid=' '");        
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: x-www-form-urlencoded'));

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
     $response = curl_exec($ch);
     echo "$response";
     curl_close ($ch);
  ?>

below is header response 下面是标题响应

      Request URL:http://localhost:8080/cgi-bin/frameset.tcl?
      sid=3514275041172666092
      Request Method:GET
      Status Code:404 Not Found
      Remote Address:[::1]:8080
      Referrer Policy:no-referrer-when-downgrade

Response Headers 响应标题

    Accept-Ranges:bytes
    Connection:Keep-Alive
    Content-Language:en
    Content-Type:text/html; charset=utf-8
    Date:Mon, 29 May 2017 06:54:33 GMT
    Keep-Alive:timeout=5, max=99
    Server:Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.4
    Transfer-Encoding:chunked
    Vary:accept-language,accept-charset

Request Headers 请求标题

  Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,
         */*;q=0.8
  Accept-Encoding:gzip, deflate, sdch, br
  Accept-Language:en-US,en;q=0.8
  Connection:keep-alive
  Cookie:PHPSESSID=hj7kbp4hp0pjq16m1tk7j3goo3; _ga=GA1.1.981975196.1489736033; XDEBUG_TRACE=XDEBUG_ECLIPSE
  DNT:1
  Host:localhost:8080
  Referer:http://localhost:8080/nias/automate.php
  Upgrade-Insecure-Requests:1
  User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36

Query String Parameters 查询字符串参数

    sid=3514275041172666092 //need to print these value

Since output was in string format and the output remains constant eachtime..needed to find the position of the required character in the string and extract the required value.. 由于输出是字符串格式,并且每次输出都保持不变。因此需要在字符串中查找所需字符的位置并提取所需值。

Below is the code 下面是代码

           $response= curl_exec($ch);//executes the curl
           echo strpos("$response","variable_to_find")."<br/>";//know the position
           $sid = substr($response,position,length);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM