Skip to content

Commit

Permalink
add getting response from callback for demo/basic.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ares333 committed Jun 19, 2018
1 parent 3d1a110 commit 434324e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions demo/basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
$toolkit = new Toolkit();
$curl = $toolkit->getCurl();
$curl->onInfo = null;
$responseCode = null;
$curl->add(
array(
'opt' => array(
CURLOPT_URL => 'http://baidu.com'
),
'args' => 'This is user arg for ' . $v
'args' => [
'This is user arg for ' . $v,
&$responseCode
]
),
function ($r, $args) {
$args[1] = $r['info']['http_code'];
echo "Request success for " . $r['info']['url'] . "\n";
echo "\nHeader info:\n";
print_r($r['info']);
Expand All @@ -23,4 +28,6 @@ function ($r, $args) {
echo strlen($r['body']) . ' bytes';
echo "\n";
});
$curl->start();
$curl->start();
echo "\nresponse code returned by reference:\n";
echo $responseCode . "\n";

0 comments on commit 434324e

Please sign in to comment.