<?php
function callback($ret, $callinfo) {
echo $callinfo['method'] , " result: ", $ret , "\n";
}
/* enregistre l'appel async aux services distants */
Yar_Concurrent_Client::call("http://example.com/operator.php", "add", array(1, 2), "callback");
Yar_Concurrent_Client::call("http://example.com/operator.php", "sub", array(2, 1), "callback");
Yar_Concurrent_Client::call("http://example.com/operator.php", "mul", array(2, 2), "callback");
/* envoi toutes les requêtes et attend les réponses */
Yar_Concurrent_Client::loop();
?>
Résultat de l'exemple ci-dessus est similaire à :
mul result: 4
sub result: 1
add result: 3