note 95343 added to function.curl-setopt

From: Date: Mon, 28 Dec 2009 15:27:54 +0000
Subject: note 95343 added to function.curl-setopt
Groups: php.notes 
Request: Send a blank email to php-notes+get-164390@lists.php.net to get a copy of this message
This: <?php $dane = array( 'name' => 'test' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost/var_dump.php'); curl_setopt($ch, CURLOPT_POSTFIELDS, $dane); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); var_dump(curl_exec($ch)); curl_close($ch); ?> will not send $_POST data. This will: <?php $dane = array( 'name' => 'test' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost/var_dump.php'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $dane); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); var_dump(curl_exec($ch)); curl_close($ch); ?> You need to set CURLOPT_POST before CURLOPT_POSTFIELDS if you are using array as data. URL encoded string is not affected by this. ---- Server IP: 82.177.164.100 Probable Submitter: 62.69.210.177 ---- Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php Edit -- https://master.php.net/note/edit/95343 Del: integrated -- https://master.php.net/note/delete/95343/integrated Del: useless -- https://master.php.net/note/delete/95343/useless Del: bad code -- https://master.php.net/note/delete/95343/bad+code Del: spam -- https://master.php.net/note/delete/95343/spam Del: non-english -- https://master.php.net/note/delete/95343/non-english Del: in docs -- https://master.php.net/note/delete/95343/in+docs Del: other reasons-- https://master.php.net/note/delete/95343 Reject -- https://master.php.net/note/reject/95343 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#164390) next »