Snippets > cURL Helper Function


#php

$result = curl([
    CURLOPT_URL             => 'http://example.com',
    CURLOPT_RETURNTRANSFER  => true
]);

print_r($result);

function curl($options)
{
    $ch = curl_init();
    curl_setopt_array($ch, $options);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}