I have a function in php and i want set a time out for its work.
for example if it's take more than 1second, return false.
function myFucntion()
{
sleep(2);
return true;
}
echo myFunction();
I want that these codes return false after one second(for example)!
Sorry for my bad english!
stream_socket_clientand infreadfunction, if server timeout, my code stuck, first i use thread and then i findstream_set_timeoutbut this question comes in mind that if this happend again, how can i handle it in general. if timeout time reached, it throw an exeption, i can handle it, but it's just kill the code instantly.