Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.