Compatibility of CURL question

I'm writing a script which needs to communicate with a remote site to perform some functions. I need to know the best way to handle this so that the script will be compatible with as many webhosts as possible. I'm looking for some advice on the compatibility of CURL. I beleive some hosts have either disabled this feature, or have not installed it. I know there are other methods I can use, but I'm not sure about their compatibility either. Can anyone offer up some suggestions for me?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Well if the libcurl package is compiled with php then CURL can fetch pages from just about any server, HTTP, GOPHER, USENET, FTP etc.

or did you mean that your script is going to run on different servers. Is it fetching pages from multiple servers or is it going to be run from multiple servers.

You can check you intallation by creating a php page with nothing but

This will desplay all the features that are available with you installalation and if you scroll down to the section under the header CURL it will either say enabled or disabled.

What might be easier and is enabled on all instillations is just using

$handle = fopen("URL",'r')

Just read the page into a buffer as you would any text file. This totally works. I've done it. Easier to use than curl too but if you need to do more than just read in a web page.. you may have to use curl.

savetheorcasAuthor Commented:
My server isn't the problem, the script will be used by others on their server and want to make sure that they are able to use all features of the script which require communication with my remote site. I'm just trying figure out what method would be the most compatible.

What are they doing with the remote site. If they just need to access a page then:


will do the trick. If your users need to send data to your server you can use

fsockopen or curl

with fsockopen you can do things like send POST variables thich your script can read in with $_POST[]. You can fake a form submission.

fsockopen is more compatible than curl. Some ISPs may not compile libcurl due to security reasons however it is pretty standard now.

If you give me an example of a task might be able to help more.

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

savetheorcasAuthor Commented:
The main task is the script connecting to my server to do two things:

1) Search for files available for download
2) Check for script updates.

Is fsockopen fairly standard with all hosts?

Yes fsock is standard with most hosts. Again this is something that an administrator could choose to disable at compile time like CURL but it is default enabled.

It sounds like fsockopen and other socket fucntions could be the way to go for you. However if you have trouble with this.

For simplicity
Just pass variables into the URL and use fopen ex.

// user version
$myver = 4;

$filename = "" . $myver;
$handle = fopen($filename,'r');

have your script return 1if there is a newer version or 0 if there isn't.

you can have another script return a list of files available for download.

To get the file there are a variety of different functions, but the easiest would be the ftp functions like
ftp_connect and ftp_get

If you are new to networking I suggest sticking with fopen and expanding if needed when you get that working.
savetheorcasAuthor Commented:
I'd prefer using something other than fopen(), CURL or fsockopen would be fine. I know that my host has disables remote fopen, so I'm going to assume other hosts have done this as well.

On average, which would you say is enables on the majority of hosts, CURL or fsock?
Maybe just  try file() :) If the script on your server would handle get method in ling ($var=_REQUEST[NAME]; ->, then file will handle it:

$mysite = file(;

Thats the best way and it will work in 100% of servers.

*"in ling"  - dunno what was that - it should be in URL
I think any ISP that would enable or disable CURL would also do the same with fsockopen. I would use fsockopen because I feel it is easier to use and understand.

You could also write the script to use both, one if the other doesn't work. Create a Connect class in which you determin what is available use that. Then include that in your script and connect through the Connect class methods. This way you can connect in different ways and you script doesn't care.

savetheorcasAuthor Commented:
Andy, can you explain this a bit more? Are you talkking about doing something checking if cUrl, etc is installed enabled on the server then calling the right function?

I'm not even sure how much concern I should have as for all I know cURL might be enabled on most hosts.
If you want to check if CURL is installed, use function_exists().

For example:
if (function_exists('curl_setopt')) { echo 'like wow! curl is installed!'; } else { echo 'och s-h-i-t... no curl ;-('; }

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.