【发布时间】:2019-09-15 23:47:59
【问题描述】:
我想在 curl 代码中连接变量,我该怎么做? 我尝试使用以下代码但不适合我,这是我的代码
$id = $_POST['id'];
$type = $_POST['type'];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://xxxxxxxxxxx.com",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_POSTFIELDS => "{\"id\":$id,\"type\":\.$type}}",
);
【问题讨论】:
-
您有语法错误。
-
那将是"interpolation",而不是串联。虽然
json_encodeing 真正的结构会更好。