Home  >  Article  >  Backend Development  >  php的curl模拟post发送数据,部分丢失解决办法

php的curl模拟post发送数据,部分丢失解决办法

WBOY
WBOYOriginal
2016-06-13 13:30:15890browse

php的curl模拟post发送数据,部分丢失
我用curl模拟post发送数据,
发送的 c/c++ 到了接收页面成了 c/c 
后面的 ++ 不见了,
另外,
post数据的时候使用 & 分开数据的,
但是要是数据本身就含有 & 符,又该怎么将 & 作为值传送,而不是作为分隔符呢??
求指教!

------解决方案--------------------
这是客户端代码

PHP code

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"http://localhost/test2.php");
curl_setopt($ch,CURLOPT_HEADER,false);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,array("param"=>"c/c++","param2"=>"df&dfdf"));
$data = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$result = array("code"=>$code,"data"=>$data);
print_r($result); <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn