Php 如何设置放置卷曲的方法?

Php 如何设置放置卷曲的方法?,php,curl,Php,Curl,我试图将Curl的http方法设置为PUT,但我的代码不起作用 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($post))); curl_setopt($curl, CURLOPT_CUSTOMREQU

我试图将Curl的http方法设置为PUT,但我的代码不起作用

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: 
  application/json','Content-Length: ' . strlen($post)));
  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
上面的代码是我写的,但它没有设置为PUT方法 请帮助

尝试更改

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');