应该使用哪个PHP函数来打开服务器上的文件? [重复]

This question already has an answer here:

I want to open a file on a remote server (e.g. http://example.org/script.php?param=000001). PHP provides several of those methods and I was wondering which method I should take and why? Are there any advantages/disadvantages?

So far I used fopen(), but after several reading-operations it happens that the server did not answer my request and fopen() failed. Afterwards I tried file_get_contents(), which also failed.

I thought it might be the server that blocked my IP, since I opened to many streams. Could this also happen with file_get_contents()?

Which method should I use, When I want to open many files on a server?

What is the technical difference between fopen() and file_get_contents()? And why should the server block my IP? (e.g. servers have limited number of open file streams,... or fopen needs more ressources)

</div>

file_get_contents() is the way to go

If you have special HTTP header requirements, use the context param

Update:

I see that you have edited the question a little bit. Note, that the difference between fopen and file_get_contents is only that the latter will open the file, read contents, close file, return the contents where the first just opens the file. The process of opening is the same.