PHP Curl PUT Request Example Code
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:
<?php
$url = "https://reqres.in/api/users/2";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
$updateArray = ['name' => 'Hardik', 'email' => 'hardik@gmail.com'];
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);
curl_close($ch);
print_r($result);
?>
i hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- PHP Curl POST Request with Headers Example
- PHP Curl Get Request with Parameters Example
- PHP Curl Request with Certificate (cert pem file option) Example
- PHP Change File Name in Folder Example
- PHP Copy File from One Folder to Another Example
- PHP Laravel Left Join Query Example
- Codeigniter Curl Post Request with Parameters Example
- PHP CURL Post Request with Parameters Example
- Laravel CURL Request Example using Ixudra/curl
- PHP Download File from URL using CURL Request Example
- How to access PHP variables in JQuery?