What I am trying to do is, I am running queries against Twitter and if the deliver of the result delays more than a specific time, than I want to say to user that "Please try again later, timeout." I am not asking the Twitter part, I told my story because of the initial explanation but I like to learn how to accomplish it with mostly PHP native codes.
What's in my mind would be something below:
startTimeout(callback(),3000);//Probably this function needs to start a new thread or another concurrent execution scope
//... initiating some twitter queries here
function callback()
{
echo "Time out, sorry";
}