Last active
October 31, 2024 15:00
-
-
Save Anahkiasen/8803434 to your computer and use it in GitHub Desktop.
curl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Object-oriented wrapper for CURL | |
*/ | |
class Curl | |
{ | |
/** | |
* The internal CURL instance | |
* | |
* @var resource | |
*/ | |
protected $curl; | |
/** | |
* Build a new Curl instance | |
* | |
* @param string $url | |
*/ | |
public function __construct($url) | |
{ | |
$this->curl = curl_init(); | |
$this->url = $url; | |
} | |
/** | |
* Set a CURL option | |
* | |
* @param string $key | |
* @param mixed $value | |
*/ | |
public function __set($key, $value) | |
{ | |
$option = constant('CURLOPT_'.strtoupper($key)); | |
curl_setopt($this->curl, $option, $value); | |
} | |
/** | |
* Send and get results | |
* | |
* @return mixed | |
*/ | |
public function send() | |
{ | |
$results = curl_exec($this->curl); | |
curl_close($this->curl); | |
return $results; | |
} | |
} |
Author
Anahkiasen
commented
Feb 4, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment