I thought I can do more at same time so I started with reactphp. The code runs so fine, but I wanted to be sure that the code was indeed asynchroneous I tried the code below which gave me no confidence, it echoed the strings 'in natural order' like "one two three four..." but I was looking for output like "one four three two..." just as it happens in javascript.
function callDone(){
$g = 'abcdefghuytegbnwsgwseeveddvvdvdcvdvbshasfcfddbbcdgcdvoiuyyttreewwaazxcvbnjjjhgfffhhhabcdefghuytegbnwsgwseeveddvvdvdcvdvbshasfcfddbbcdgcdvoiuyyttreewwaazxcvbnjjjhgfffhhh';
$r = str_split($g);
for($i=0;$i<count($r);$i++){
$g .= $r[$i];
}
return 1;
}
$promise = new React\Promise\Promise(function($resolve){
echo microtime(true). "<br>start<br>";
$resolve(callDone());
}
$promise->then(function($v){
echo 'one<br>';
});
$promise->then(function($v){
echo 'two<br>';
});
$promise->then(function($v){
echo 'three<br>';
});
$promise->then(function($v){
echo 'four<br>';
});
$promise->then(function($v){
echo 'five<br>';
});
this will print "one two three four five" But I needed something out of order like: "one three two..." to confirm this is really asynchroneous. Any help thanks in advance.