I do not know what your purpose is, but
Using timeout to request one or another request is not as good practice, usually timeout should be used to 'catch' service response errors and prevent your server from hanging up waiting for a response
If there is no other option, you can achieve what you want:
You can use the curl for PHP and use the CURLOPT_TIMEOUT
option to assign a response time .
To run a certain code when the% co_of% ends, you should use timeout
.
$ch = curl_init();
$timeout = 5; //segundos
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
if (curl_errno($ch) == 28){ // 28 -> CURLE_OPERATION_TIMEDOUT
//timeout, código para el segundo request
}
curl_close($ch);
PHP Curl
Curl Errno