Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Grabbing A Remote File


Simsi - 8:27 am on Feb 27, 2008 (gmt 0)


Hi

I am writing a PHP script that grabs a set of relatively small (max 500 lines of text) files from a remote URL (referenced via [www...] as opposed to an IP address). I have identified 4 potential methods for grabbing the file and saving it to a local file: fopen(), curl, fsockopen() and file_get_contents().

Because the script will be run by multiple users, I won't know which method(s) their server supports, so I do a test to determine which is viable and store the result in a config file. Which of these methods is the most efficient, or in what order would you test for compatibility?

A the moment I have it set to test fopen(), file_get_contents(), fsockopen() and curl in that order - but I'd rather have the most efficient one first obviously so if it's available, it will become the default method on that server.

Many thanks

Ian

[edited by: Simsi at 8:30 am (utc) on Feb. 27, 2008]


Thread source:: http://www.webmasterworld.com/php/3585915.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com