note 99108 added to function.curl-setopt
| From: | sam at def dot reyssi dot net | Date: | Wed, 28 Jul 2010 10:43:10 +0000 |
| Subject: | note 99108 added to function.curl-setopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171182@lists.php.net to get a copy of this message | ||
Be careful when setting the CURLOPT_POSTFIELDS setting using an array. The array used to set the
POST fields must only contain scalar values. Multidimentional arrays or objects lacking a __toString
implementation will cause Curl to error.
If there is a need to send non-scalar values using a POST request, consider serializing them before
transmission.
<?php
$ch = curl_init('http://some.domain.tld');
// Data to post
$multiDimensional = array(
'name' = 'foo',
'data' = array(1,2,3,4),
'value' = 'bar'
);
// Will error
curl_setopt($ch, CURLOPT_POSTFIELDS, $multiDimensional);
// Data to post
$postData = array(
'name' = 'foo',
'data' = serialize(array(1,2,3,4)),
'value' = 'bar'
);
// Will not error
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
----
Server IP: 69.147.83.197
Probable Submitter: 62.208.225.86 (proxied: 148.185.9.27)
----
Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php
Edit -- https://master.php.net/note/edit/99108
Del: integrated -- https://master.php.net/note/delete/99108/integrated
Del: useless -- https://master.php.net/note/delete/99108/useless
Del: bad code -- https://master.php.net/note/delete/99108/bad+code
Del: spam -- https://master.php.net/note/delete/99108/spam
Del: non-english -- https://master.php.net/note/delete/99108/non-english
Del: in docs -- https://master.php.net/note/delete/99108/in+docs
Del: other reasons-- https://master.php.net/note/delete/99108
Reject -- https://master.php.net/note/reject/99108
Search -- https://master.php.net/manage/user-notes.php