← All built-ins / http_request()

http_request()

http_request(...$args): mixed

Parameters

NameTypeDescription
$urlstringhttp:// URL
$methodstringHTTP verb: "PUT", "DELETE", … (default "GET")
$bodystringrequest bodyoptional
$headersarrayheader linesoptional

Return value

Response map like http_get(), or false on failure.

Example

$r = http_request("http://localhost:1/unreachable", "PUT", "data");
echo $r === false ? "offline-safe" : "unexpected";
offline-safe

See also

http_get()http_post()