How to check if Curl is available on your PHP Server?

First you can try phpinfo() function as shown in the below example. Create a file called phpinfo.php and add below code:

<?php
phpinfo();

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:
    <?php
    var_dump(extension_loaded('curl'));
    

    When you run this script it should show you bool(true) as its output if curl support is enabled on your PHP server.

Comments

So empty here ... leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

Sidebar



Do NOT follow this link or you will be banned from the site!