Home>Article>Backend Development> How to solve curl php post loss problem
php curl post data is lost because in the string type, the & symbol is used to separate parameters, so it will cause loss. The solution is to submit it using Array.
The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer
How to solve the curl php post loss problem?
About the problem of data loss in 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 parameters have two types: string/array
For example: we want to submit two data
$title = '我是标题'; $content = '点我百度一下';
When the type is string
$data = 'title=这是标题&content=点我百度一下';
After submission, we will find that $_POST['content'] does not appear as we want1552f1ccb0bfbba19f5dd9237290201eClick on Baidu5db79b134e9f6b82c0b36e0489ee08ed, butArray( [title] => 我是标题 [content] => 点我百度一下 )
At this time, we only need to use Array to submit and there will be no problemRecommended learning : "The above is the detailed content of How to solve curl php post loss problem. For more information, please follow other related articles on the PHP Chinese website!