Skip to content

Instantly share code, notes, and snippets.

@SparK-Cruz
Created June 20, 2018 18:42
Show Gist options
  • Save SparK-Cruz/79da1526e0a9c1a44d5ed24bcaf375c2 to your computer and use it in GitHub Desktop.
Save SparK-Cruz/79da1526e0a9c1a44d5ed24bcaf375c2 to your computer and use it in GitHub Desktop.
My default curl usage
<?php
trait Requestable {
private function getRequest($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
try {
return [curl_exec($curl), curl_errno($curl)];
} finally {
curl_close($curl);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment