Mecha CMS

Helper functions.

fetch

Fetch contents from a remote URL.

2.2.0

fetch(string $url, string $agent = null, string $type = 'GET');
fetch(string $url, array $lot = [], string $type = 'GET');

Example:

$A = fetch('https://example.com');
$B = fetch('https://example.com', $_SERVER['HTTP_USER_AGENT']);
$C = fetch('https://example.com', [
    'user-agent' => $_SERVER['HTTP_USER_AGENT'],
    'x-foo' => 1,
    'x-bar' => 2
]);

// Send `POST` request with data as URL query
$D = fetch('https://example.com?foo=bar&baz=qux', [], 'POST');