note 95343 deleted from function.curl-setopt by danbrown

From: Date: Mon, 28 Dec 2009 17:59:07 +0000
Subject: note 95343 deleted from function.curl-setopt by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164396@lists.php.net to get a copy of this message
Note Submitter: paziek at gmail dot com ---- 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.

« previous php.notes (#164396) next »