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.
高洛峰
高洛峰 2017-05-16 13:10:38
0
3
604

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>
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(3)
巴扎黑

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

Search for the specific meaning by yourself

过去多啦不再A梦

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

阿神

$rt == 1

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template