timeout.php 458 B

1234567891011121314151617
  1. <?php
  2. // First, include Requests
  3. include('../library/Requests.php');
  4. // Next, make sure Requests can load internal classes
  5. Requests::register_autoloader();
  6. // Define a timeout of 2.5 seconds
  7. $options = array(
  8. 'timeout' => 2.5,
  9. );
  10. // Now let's make a request to a page that will delay its response by 3 seconds
  11. $request = Requests::get('http://httpbin.org/delay/3', array(), $options);
  12. // An exception will be thrown, stating a timeout of the request !