PDA

View Full Version : Testing for fopen and cURL


CyberRanger
07-05-2006, 01:33 AM
I'd like to be able to test if a site has fopen on and cURL installed. Testing for fopen seems simple enough but how can I test for cURL? Do I need to do phpinfo and search the results cURL? What is phpinfo is not allowed?

Basic code structure:

if(ini_get('allow_url_fopen')
{
// fopen is on
}
elseif (some test for cURL???)
{
// cURL is installed
}
else
{
// neither fopen or cURL are available
}

Code Monkey
07-05-2006, 01:43 AM
if(function_exists('curl_init'))
{
// code
}


You should use curl as a first option though.

Paul M
07-05-2006, 01:49 AM
Or check if one of the predefined constants exists, e.g. CURLOPT_FILE

A full list can be found here as well as the list of functions.

http://uk.php.net/curl

CyberRanger
07-05-2006, 01:51 AM
Thanks!