php curl post数据丢失是因为在string类型中,&符号是在分割参数用的,所以会导致丢失情况,其解决办法就是使用Array的方式提交即可。

本文操作环境:Windows7系统、PHP7.1版,DELL G3电脑
如何解决curl php post 丢失问题?
关于PHP Curl POST 数据丢失的问题
$ch = curl_init (); curl_setopt ( $ch, CURLOPT_URL, $uri ); curl_setopt ( $ch, CURLOPT_POST, 1 ); curl_setopt ( $ch, CURLOPT_HEADER, 0 ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data ); $return = curl_exec ( $ch ); curl_close ( $ch );
$data参数有两种类型:string/array
立即学习“PHP免费学习笔记(深入)”;
比如:我们想提交两个数据
$title = '我是标题'; $content = '<a href="http://www.baidu.com?a=1&b=1">点我百度一下</a>';
当类型为string的时候
$data = 'title=这是标题&content=<a href="http://www.baidu.com?a=1&b=1">点我百度一下</a>';
提交后我们会发现$_POST['content']并没有出现我们想要的点我百度一下,而是出现了Array(
[title] => 我是标题
[content] => <a href="http://www.baidu.com?a=1
[b] => 1">点我百度一下</a>
)
%E8%BF%99%E6%97%B6%E6%88%91%E4%BB%AC%E5%8F%AA%E8%A6%81%E4%BD%BF%E7%94%A8Array%E7%9A%84%E6%96%B9%E5%BC%8F%E6%8F%90%E4%BA%A4%E5%B0%B1%E6%B2%A1%E6%9C%89%E9%97%AE%E9%A2%98%E4%BA%86
%E6%8E%A8%E8%8D%90%E5%AD%A6%E4%B9%A0%EF%BC%9A%E3%80%8APHP视频教程》
以上就是如何解决curl php post 丢失问题的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号