Doc #69644 [Com]: additional note for CURLOPT_POSTFIELDS
| From: | pasindu@php.net | Date: | Wed, 23 Sep 2015 18:48:41 +0000 |
| Subject: | Doc #69644 [Com]: additional note for CURLOPT_POSTFIELDS | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-12776@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69644&edit=1
ID: 69644
Comment by: pasindu@php.net
Reported by: tjw at tjw dot org
Summary: additional note for CURLOPT_POSTFIELDS
Status: Open
Type: Documentation Problem
Package: Documentation problem
Operating System: ALL
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
In PHP 7 CURLOPT_POST dose not have to be set, in CURLOPT_POSTFIELDS a string is treated as a query
string and array will be converted
http://lxr.php.net/xref/PHP_TRUNK/ext/curl/interface.c#2501
Previous Comments:
------------------------------------------------------------------------
[2015-05-15 21:00:30] tjw at tjw dot org
Description:
------------
If curl_setopt() is used to set CURLOPT_POSTFIELDS with an array, it will not work unless
CURLOPT_POST has been set to true first.
This works:
$parameters = array("test" => "testing");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
This posts and empty form:
$parameters = array("test" => "testing");
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch, CURLOPT_POST, TRUE);
However, this works:
$parameters = "test=testing";
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch, CURLOPT_POST, TRUE);
It would be very helpful if a note was added in the documentation for CURLOPT_POSTFIELDS that
CURLOPT_POST must be set to true before passing an array or it will not be automatically converted
to a query string.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69644&edit=1