note 96313 modified in function.curl-setopt by thiago
| From: | thiago@php.net | Date: | Mon, 22 Feb 2010 03:01:58 +0000 |
| Subject: | note 96313 modified in function.curl-setopt by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166240@lists.php.net to get a copy of this message | ||
You can use also use object methods as callback functions. This is usefull if your curl ressource is
part of an object handling transfers.
Instead of curl_setopt($curl, CURLOPT_WRITEFUNCTION, "curl_handler_recv") you can use
array($object, "method") as value for callback options.
For example:
<?php
class downloader {
private $curl;
function __construct() {
$this->curl = curl_init();
curl_setopt($this->curl, CURLOPT_WRITEFUNCTION, array($this,
"curl_handler_recv"));
}
function curl_handler_recv($res, $data) {
//...
}
//...
}
?>
--was--
You can use also use object methods as callback functions. This is usefull if your curl ressource is
part of an object handling transfers.
Instead of curl_setopt($curl, CURLOPT_WRITEFUNCTION, "curl_handler_recv") you can use
array($object, "method") as value for callback options.
For example:
class downloader {
private $curl;
function __construct() {
$this->curl = curl_init();
curl_setopt($this->curl, CURLOPT_WRITEFUNCTION, array($this,
"curl_handler_recv"));
}
function curl_handler_recv($res, $data) {
...
}
...
}
http://php.net/manual/en/function.curl-setopt.php