search

Home  >  Q&A  >  body text

I would like to ask you a question that a PHP novice may encounter: using curl to make a post request with multiple 1s behind the result.

Same as the title; Use PHP's curl to send a post request; the data can be obtained, but there is an extra number 1 in the json string returned by the server. I checked the code and couldn't find when it was Added, Baidu can't find any information on this aspect at all, it should only be encountered by novices like me;

The request interface cannot be sent due to confidentiality reasons, the code is as follows:

<?php
$url = "Domain name:9789/interface";
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST,1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, "goodsId=56");
  $rt = curl_exec($ch);
  curl_close($ch);
  echo $rt;

Page output:

{"model":{"id":1},"onTop":2,"soldCount":0,"result":0,"timeMillis":1492765168804}1< /code>
高洛峰高洛峰2752 days ago605

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-05-16 13:12:38

    Add this
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    Search for the specific meaning by yourself

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 13:12:38

    This 1 should be returned by your interface. You should look at where your 9789 interface is.

    reply
    0
  • 阿神

    阿神2017-05-16 13:12:38

    $rt == 1

    reply
    0
  • Cancelreply