I would like to know what would happen if I have a code like that in a php page doit.php:
$url="http://someServer.com/somepage.php";
$i=10;
while($i--){
getDataFromAnotherServer($url);
}
now, knowing that function getDataFromAnotherServer() can take up to a second or two…
What would happen if a user is asking for that doit.php and immediately close the browser ?
Would the function still be called 9 times (the loop would reach i==0) or stop somewhere in the middle?
Thanks
The script will be aborted (unless there is no attempt to send data to the client during that time). To prevent the script from ending early due to client disconnect, use ignore_user_abort.
More detailed info on PHP connection handling can be found here:
http://www.php.net/manual/en/features.connection-handling.php