Jump to content

file(); timout?


Hyaku_

Recommended Posts

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!
Link to comment
https://forums.phpfreaks.com/topic/33775-file-timout/
Share on other sites

You could set a timeout for the whole script...

[code]<?php
ini_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.

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/33775-file-timout/#findComment-158379
Share on other sites

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 options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/file.htm"); // url to open
curl_setopt(CURLOPT_TIMEOUT, 10); // set timeout
curl_setopt(CURLOPT_HEADER, false); // don't include header output
curl_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 resources
curl_close($ch);
?>[/code]

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/33775-file-timout/#findComment-158950
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.