MattsBits
MattsBits

MattsBits

Script to check if CURL is enabled on your server  

by Matt Hawkins, 01/04/2012
Categories : PHP & MySQL

cURL is a useful PHP library that allows you to connect to servers using a variety of different protocols. These include HTTP,FTP, LDAP and HTTPs.

The following PHP script allows you to check if it is enabled on your web server. If your server is provided by a web hosting company this will allow you determine if it is available to you. Some web hosts may disable cURL which would stop some PHP
scripts from running properly.

To use the curl check script paste the following in a text file named "curl_check.php" :


<?php
// Script to test if the CURL extension is installed on this server

// Define function to test
function _is_curl_installed() {
	if  (in_array  ('curl', get_loaded_extensions())) {
		return true;
	}
	else {
		return false;
	}
}

// Ouput text to user based on test
if (_is_curl_installed()) {
  echo "cURL is <span style="color:blue">installed</span> on this server";
} else {
  echo "cURL is NOT <span style="color:red">installed</span> on this server";
}
?>


Upload "check_curl.php" to your website root.

You can perform the check by entering http://www.example.com/curl_check.php into your browser. Where example.com is your website.

Once you have performed your test remove the script from your web server.

An alternative is to use this script :
<?
phpinfo();
?>

When run this will list all the extensions available to your web server. You can check to see if cURL is listed.

Author : Matt Hawkins  Last Edit By : Matt Hawkins
PHP Powered  MySQL Powered  Valid XHTML 1.0  Valid CSS  Firefox - Take Back The Web  EUKHost - Recommended Webhosting Solutions

MattHawkins CMS v3.0 - Copyright 2009-2013