Out of these, which one do you use most and why ?
fsockopen, curl, fopen, file_get_contents,
Out of these, which one do you use most and why ?
Out of these, which one do you use most and why ?
fsockopen, curl, fopen, file_get_contents,
Out of these, which one do you use most and why ?
The question makes little sense, theses functions are not identical, I use what's appropriate to the task at hand.
I have not said that they are identical !!! ?
Would appreciate any input for coders that do understand these.
methods: fsockopen, curl, fopen, file_get_contents.
There are many occasions when you can get your result
using 2 or 3 of these methods and you need to decide which
is the most appropiate one to select.
I have not used fsockopen, but the others I have used
and want to learn more from experienced coders.
Knowing the reasons for selecting one function over another
for a certain task will be helpful.
Perhaps I should have explained this in my first post
my mistake, i jumped the gun. My answer is still what ever is appropriate for the job, i can't see any other way to answer your query.
I guess i could search a few million lines of my code and count the occurrence of each, but i'm not sure that's very helpful. There are few things that cant be done a several different ways, in life and php.
A question like "In situation A .." which is the best choose, may get you what your after. If you want examples of each, the manual is usually the first place to go.
I guess i could search a few million lines of my code
Yes , that would be helpful.
Let me know when you have done it
file_get_contents/file_put_contents with appropriate wrappers usually serves most purposes. There are times when they do not, operating on big files can be problematic, plus a real handle is useful sometimes when dealing with sockets - one example that springs to mind was reading from a socket into fgetcsv().
Personally I use them in the following ways:
fsockopen
[indent]Used to do a quick check for URLs and get response codes. Nothing fancy, but quick and dirty and I don't need CURL to do it. It's just a preference as I could easily use fopen with any of the stream wrappers instead of fsockopen.[/indent]
fopen
[indent]Personally I use this as writing strictly locally to files or output streams (like downloads).[/indent]
CURL
[indent]I use this only for times when I need to do http requests that somehow depend upon one another or have cookies. It's easier to use typically than strictly fsockopen or fopen.[/indent]
file_get_contents
[indent]I use this only when dealing with local files or a simple http read.[/indent]
Of course, all of these depend upon the situation I'm working in.