chained_task.php 637 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. require_once '_inc.php';
  3. use Ares333\Curl\Toolkit;
  4. $toolkit = new Toolkit();
  5. $toolkit->setCurl();
  6. $curl = $toolkit->getCurl();
  7. $curl->onInfo = null;
  8. $url = 'http://baidu.com';
  9. $curl->add(array(
  10. 'opt' => array(
  11. CURLOPT_URL => $url
  12. )
  13. ), 'cb1');
  14. echo "add $url\n";
  15. $curl->start();
  16. function cb1($r, $args)
  17. {
  18. echo "finish " . $r['info']['url'] . "\n";
  19. $url = 'http://bing.com';
  20. $r['curl']->add(
  21. array(
  22. 'opt' => array(
  23. CURLOPT_URL => $url
  24. )
  25. ), 'cb2');
  26. echo "add $url\n";
  27. }
  28. function cb2($r, $args)
  29. {
  30. echo "finish " . $r['info']['url'] . "\n";
  31. }