← All built-ins / http_post()

http_post()

http_post(...$args): mixed

Parameters

NameTypeDescription
$urlstringhttp:// URL
$bodystringrequest body
$headersarrayheader lines like "Content-Type: application/json"optional

Return value

Same map as http_get(), or false on failure.

Example

$r = http_post("http://localhost:1/unreachable", "a=1", ["Content-Type: application/x-www-form-urlencoded"]);
echo $r === false ? "offline-safe" : "unexpected";
offline-safe

See also

http_get()http_build_query()http_request()