php send put request

Solutions on MaxInterview for php send put request by the best coders in the world

showing results for - "php send put request"
Johanna
06 May 2017
1<?php
2 
3//The URL that we want to send a PUT request to.
4$url = 'http://localhost/tester/log.php';
5 
6//Initiate cURL
7$ch = curl_init($url);
8 
9//Use the CURLOPT_PUT option to tell cURL that
10//this is a PUT request.
11curl_setopt($ch, CURLOPT_PUT, true);
12 
13//We want the result / output returned.
14curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
15 
16//Our fields.
17$fields = array("id" => 1);
18curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
19 
20//Execute the request.
21$response = curl_exec($ch);
22 
23echo $response;
24