coro_destuct.php 656 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. require __DIR__ . "/coro_include.php";
  3. class T
  4. {
  5. function __construct()
  6. {
  7. echo "call __construct \n";
  8. }
  9. function test()
  10. {
  11. echo "call function \n";
  12. }
  13. function __destruct()
  14. {
  15. echo "call __destruct \n";
  16. go(function () {
  17. echo "co[1] start\n";
  18. $client = new Swoole\Coroutine\Client(SWOOLE_SOCK_TCP);
  19. $res = $client->connect('127.0.0.1', 9501, 1);
  20. co::sleep(1.0);
  21. echo "co[1] resume : connect ret = ".var_export($res,1)."\n";
  22. echo "co[1] exit\n";
  23. });
  24. }
  25. }
  26. $t = new T();
  27. $t->test();
  28. unset($t);