Answers for "php send put request"

PHP
1

php send put request

<?php
 
//The URL that we want to send a PUT request to.
$url = 'http://localhost/tester/log.php';
 
//Initiate cURL
$ch = curl_init($url);
 
//Use the CURLOPT_PUT option to tell cURL that
//this is a PUT request.
curl_setopt($ch, CURLOPT_PUT, true);
 
//We want the result / output returned.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
//Our fields.
$fields = array("id" => 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
 
//Execute the request.
$response = curl_exec($ch);
 
echo $response;
Posted by: Guest on November-10-2020

Browse Popular Code Answers by Language