setOption() public method

Set cURL session option(s).
public setOption ( array | integer $opt, string $val = null ) : Curl
$opt array | integer
$val string
return Curl
Beispiel #1
0
 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));
 }
Beispiel #2
0
<?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;
}