Skip to content
Advertisement

file_get_contents() Timeout in php

I know php doesn’t give timeout option since it is running from server side. But my logic needs timeout. Please solve this case

My PHP: login.php :-

JavaScript

my html index.html :-

JavaScript

This javascript is not working. and obviously delay will happen in server code and i cannot watch it from client side.

so this is what i want. need to terminate submission process (from submit to rendering next page) if my file_get_contents() function is not responding for long.

Note: Please dont ask me to use curl, Because i am instructed to not use curl. and i cant get it in client side

Advertisement

Answer

The default value for a timeout in file_get_contents() is 60 seconds. You can change this value through the default_socket_timeout setting. It’s also doable in your code:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement