Can i set an time out for a fopen function ? I wan't to open websites but to not wait for 30 seconds if the websites are down , only 2-3 seconds. How can i do it without curl?!
You could use fsockopen(), which takes a timeout parameter. Then call set_stream_timeout(), which will set the timeout for subsequent read operations. See the fsockopen manual page for more details: http://us3.php.net/manual/en/function.fsockopen.php
Also try file_get_contents and see if it works better. Sometimes other sites are just too slow for either to work effectively.
Well, you *could*, but the only way to control the timeout would be to create a stream context, set the timeout on that (as previously described), and then pass that context in to file_get_contents. However, stream contexts with file_get_contents can be persnickety, so this isn't really recommended.