Skip to content
Advertisement

cURL contains an invalid cURL option

I was upgrading from PHP 7.4 to PHP 8 and suddenly this errors appears in my cURL request:

JavaScript

I use the following code to build the curl:

JavaScript

The targeted file is always an php extensions. ‘buildPostFields’ returns an array of the data.

Probably this errors accours because of my php upgrade to version 8, but I cannot find any hints in the documentation. I tried removing every line and then tried again. But it didn’t help.

Advertisement

Answer

The error is because you wrapped the constants with double quotes.

curl_setopt_array ( CurlHandle $handle , array $options ) : bool

options
An array specifying which options to set and their values. The keys should be valid curl_setopt() constants or their integer equivalents.

So it should be CONSTANT_NAME => value

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement