public function testSetAndGetOptions() { $c = new Curl('http://www.popphp.org/version', array(CURLOPT_RETURNTRANSFER => true)); $c->setOption(CURLOPT_HEADER, false); $this->assertEquals(1, $c->getOption(CURLOPT_RETURNTRANSFER)); $this->assertEquals(0, $c->getOption(CURLOPT_HEADER)); }
<?php require_once '../../bootstrap.php'; use Pop\Curl\Curl; try { $total = 0; $curl = new Curl('http://www.popphp.org/license'); $curl->setOption(CURLOPT_WRITEFUNCTION, function ($curl, $data) { global $total; $len = strlen($data); $total += $len; echo $len . ' (' . $total . ')<br />' . PHP_EOL; return $len; }); $curl->execute(); } catch (\Exception $e) { echo $e->getMessage() . PHP_EOL . PHP_EOL; }