PHP Curl PUT Request Example Code

By Hardik Savani November 5, 2023 Category : PHP

In this example, you will learn php curl put request example. I’m going to show you about put method in curl php. you'll learn php curl put request with body. i explained simply step by step how to call put request with data using php curl.

i will give you two very simple example here, one simple put request with php curl. so let's see bellow examples:

PHP Curl PUT Request:


$url = "";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

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

$updateArray = ['name' => 'Hardik', 'email' => ''];

curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($updateArray));

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$headers = [];

$headers[] = 'Content-Type:application/json';

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);

$result = json_decode($result);




i hope it can help you...

Tags :