Sample code for 30+ languages & platforms
PHP

HTTP DELETE with Body

See more HTTP Examples

Demonstrates how to send a DELETE request with a body.

Chilkat PHP Downloads

PHP
<?php

use Chilkat2\Http;
use Chilkat2\HttpResponse;

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

$http = new Http();

// Use the HttpStr method (or HttpSb) to send a DELETE request with a body.
$requestBody = '{ "abc": 123 }';
$resp = new HttpResponse();
try {
    $http->HttpStr('DELETE', 'https://example.com/something', $requestBody, 'utf-8', 'application/json', $resp);
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
    exit;
}

echo 'Response status: ', $resp->StatusCode, "\n";
echo "Response body: \n";
echo $resp->BodyStr, "\n";