First you can try phpinfo() function as shown in the below example. Create a file called phpinfo.php and add below code:
When you save and run this script, the phpinfo() function will dump all the configuration information of your PHP installation. Scroll down until you see the word ‘Curl’ or hit Ctrl + F to enable browser search and type ‘Curl’. If Curl is enabled should see it is highlighted in the phpinfo() output. If you can’t find ‘Curl’ in the output your PHP installation doesn’t have Curl support enabled.
phpinfo() function may not work all the time. Especially if your server admin has disabled phpinfo() for security reasons you won’t be able to see anything by using this function. In such cases we have a couple of alternative ways to determine curl’s availability:
- 1. You can use PHP’s function_exists() function to check if any curl related function is available. For an example below code shows how function_exists() is used to check whether ‘curl_version’ function is available:
<?php echo function_exists('curl_version');
If the function exists the above code will show 1. That means the function is available and so does Curl.
- 2. You can also use PHP’s extension_loaded() function to check if ‘curl’ extension is loaded. If it does, this function will return true that also indicates curl’s availability:
When you run this script it should show you bool(true) as its output if curl support is enabled on your PHP server.