Featured Articles

Video Introduction to Newsletter Booster for WordPress

Introduction video to Newsletter Booster - WordPress plugin.

SEO Booster PRO 2 Teaser

It stores a lot of nifty information about the link, if its nofollow, an image or a text link, and i[...]

How To Check if the cURL PHP extension is loaded

by Lars Koudal on 03/07/2009

443 views so far.

Share

There is not a lot of information about checking if a particular extension is loaded and the few tidbits there are on the internet, are very impractical, so I decided to dig a bit deeper and I came up with my own solution.

The following function returns TRUE if it can find the cURL extension installed, and FALSE if it fails to find it.

// ### Checks for presence of the cURL extension.
function _iscurlinstalled() {
	if  (in_array  ('curl', get_loaded_extensions())) {
		return true;
	}
	else{
		return false;
	}
}

Sample usage:

if (_iscurlinstalled()) echo "cURL is installed"; else echo "cURL is NOT installed";

Popular Searches
php test curl, The Curl extension is required. , php curl test, php check curl, php check if curl is installed, check curl php, test curl php, curl php extension, php check for curl, check curl, php check if curl is enabled, test curl, check if curl is installed php, check if curl is enabled, Curl extension, php curl extension, php curl check, curl test, curl php test, php check curl installed, test php curl, curl test php, how to test curl php, check for curl, check if curl is installed,

{ 5 comments… read them below or add one }

Dmitry July 4, 2009 at 04:20

You may also use ‘function_exists’ function to check that. Simple code will be:
echo ‘cURL is’.(function_exists(‘curl_open’) ? ” : ‘ not’).’ installed’;

Reply

myWordPress July 4, 2009 at 06:50

Hi Dmitry

Auch, that code is so much cleaner and simpler. Thank you for that tip, I never even thought to use the function_exists() function.

Thanks :-)

Reply

Moondog604 February 4, 2010 at 10:06

Dmitry there is an error with your code. I was testing and of course it was giving me a false positive. curl_open is not a function, curl_init is what you should have tested with. Once I made the change I was getting a message saying cURL was enabled.

echo ‘cURL is’.(function_exists(‘curl_init’) ? ” : ‘ not’).’ installed’;

Reply

emil August 6, 2010 at 15:16

`if ( function_exists(‘curl_version’) == “Enabled” ){ //do something; };`
Virker også fint. // works a charm.

Reply

Lars Koudal August 6, 2010 at 16:44

Hi Emil

I see my initial post was complete overkill, your method is definitely better to use :-)

Reply

Leave a Comment

PRIVACY POLICY: Your privacy is important to us. We will never sell or rent your email address and you can unsubscribe at any time.

Previous post:

Next post: