We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Compatibility of CURL question

savetheorcas asked
Medium Priority
Last Modified: 2008-03-10
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?

Watch Question

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.



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.



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 = "http://www.myhost.com/updater.php?v=" . $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.


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]; -> http://myserver.com/index.php?NAME=My%20Name), then file will handle it:

$mysite = file(http://myserver.com/index.php?NAME=My%20Name);

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.


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 ;-('; }

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.