Hyaku_ Posted January 11, 2007 Share Posted January 11, 2007 Hi!In PHP manual, it says:[code]Tip: You can use a URL as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename and Appendix M for a list of supported URL protocols.[/code]What does it timeout and is it posible to specify my own timeout for it? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/33775-file-timout/ Share on other sites More sharing options...
HuggieBear Posted January 11, 2007 Share Posted January 11, 2007 You could set a timeout for the whole script...[code]<?phpini_set('max_execution_time','10');?>[/code]This is set to 30 by default in the php.ini file.Alternatively, if you want to set a timeout for that one command, then you're better off using the CURL library.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/33775-file-timout/#findComment-158379 Share on other sites More sharing options...
Hyaku_ Posted January 11, 2007 Author Share Posted January 11, 2007 Thanks!Yeah, I need to set timout just for that function, because I need to read file from remote server and if it the server doesn't respond in ex. 10sec, then continue to execute script. Quote Link to comment https://forums.phpfreaks.com/topic/33775-file-timout/#findComment-158394 Share on other sites More sharing options...
HuggieBear Posted January 12, 2007 Share Posted January 12, 2007 In that case I'd go for the CURL option and use something like this:[code]<?php//Assign a new CURL instance to a handle$ch = curl_init();// Set the optionscurl_setopt($ch, CURLOPT_URL, "http://www.example.com/file.htm"); // url to opencurl_setopt(CURLOPT_TIMEOUT, 10); // set timeoutcurl_setopt(CURLOPT_HEADER, false); // don't include header outputcurl_setopt(CURLOPT_RETURNTRANSFER, true); // return details to a string rather than browser// grab URL and pass it into a string$file = curl_exec($ch);// close CURL resource, and free up system resourcescurl_close($ch);?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/33775-file-timout/#findComment-158950 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.