How to check if curl is enabled or disabled

前端 未结 7 1443
孤城傲影
孤城傲影 2020-11-27 04:07

Possible Duplicate:
Writing a function in php

I\'m using the following code

echo \'Curl: \',          


        
相关标签:
7条回答
  • 2020-11-27 04:25

    You can always create a new page and use phpinfo(). Scroll down to the curl section and see if it is enabled.

    0 讨论(0)
  • 2020-11-27 04:28
    <?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";
    }
    ?>
    

    or a simple one -

    <?
    phpinfo();
    ?>
    

    Just search for curl

    source - http://www.mattsbits.co.uk/item-164.html

    0 讨论(0)
  • 2020-11-27 04:30
    var_dump(extension_loaded('curl'));
    
    0 讨论(0)
  • 2020-11-27 04:30

    Its always better to go for a generic reusable function in your project which returns whether the extension loaded. You can use the following function to check -

    function isExtensionLoaded($extension_name){
        return extension_loaded($extension_name);
    }
    

    Usage

    echo isExtensionLoaded('curl');
    echo isExtensionLoaded('gd');
    
    0 讨论(0)
  • 2020-11-27 04:34

    Hope this helps.

    <?php
        function _iscurl() {
            return function_exists('curl_version');
        }
    ?>
    
    0 讨论(0)
  • 2020-11-27 04:40

    you can check by putting these code in php file.

    <?php
    if(in_array  ('curl', get_loaded_extensions())) {
        echo "CURL is available on your web server";
    }
    else{
        echo "CURL is not available on your web server";
    }
    

    OR

    var_dump(extension_loaded('curl'));
    
    0 讨论(0)
提交回复
热议问题