Welcome to WebmasterWorld Guest from 126.96.36.199
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.
[edited by: Simsi at 8:30 am (utc) on Feb. 27, 2008]
[edited by: Vis3R at 12:49 am (utc) on Feb. 28, 2008]
Funnily enough, file_get_contents() was the one I seemed to get on best with in testing too, but my instinct told me CURL would be more efficient, where present.
My experience has been the opposite, in the context of presence:
file_get_contents() is the most simple and easy to use, when present (or better said, "when allowed"), however cURL is more reliable across hosts.