How check curl is installed or not in php?

Possible Duplicate:
Writing a function in php

I'm using the following code

echo 'Curl: ', function_exists('curl_version') ? 'Enabled' : 'Disabled';

this can get it enabled or disabled

but I would like to make as function say function name is _iscurl

then I can call it as following any where in my website code

if (_iscurl()){
  echo "this is enabled"; // will do an action
}else{
  echo "this is disabled"; // will do another action
}

almost same as my previous question check if allow_url_fopen is enabled or not

Cœur

35.5k24 gold badges188 silver badges257 bronze badges

asked Nov 17, 2012 at 19:21

How check curl is installed or not in php?

Reham FahmyReham Fahmy

4,80315 gold badges49 silver badges70 bronze badges

2

Just return your existing check from a function.

function _isCurl(){
    return function_exists('curl_version');
}

answered Nov 17, 2012 at 19:23

1

installed on this server";
} else {
  echo "cURL is NOT installed on this server";
}
?>

or a simple one -


Just search for curl

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

da5id

9,0308 gold badges38 silver badges53 bronze badges

answered Nov 17, 2012 at 19:28

Amit PandeyAmit Pandey

1,3661 gold badge22 silver badges34 bronze badges

var_dump(extension_loaded('curl'));

mpen

261k259 gold badges814 silver badges1187 bronze badges

answered May 4, 2014 at 13:01

Alex SAlex S

6896 silver badges8 bronze badges

3

Hope this helps.


How check curl is installed or not in php?

answered Nov 17, 2012 at 19:25

2

you can check by putting these code in php file.

OR

var_dump(extension_loaded('curl'));

answered Apr 26, 2017 at 7:54

manish2706manish2706

1,52124 silver badges20 bronze badges

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

answered Nov 17, 2012 at 19:24

Samuel CookSamuel Cook

16.2k6 gold badges48 silver badges61 bronze badges

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');

answered Jun 25, 2016 at 7:05

5

How do you check PHP cURL installed or not?

For anyone that wants to quickly check on the command line without creating a file: echo "" ... .
or: php -i | grep curl or php -r 'var_dump(extension_loaded("curl"));' ^^ – hakre. ... .
just put this into a phpinfo file, into the first line: `

How do I know if cURL is installed?

To check whether the Curl package is installed on your system, open up your console, type curl , and press enter. If you have curl installed, the system will print curl: try 'curl --help' or 'curl --manual' for more information .

Is cURL included in PHP?

cURL is a PHP library and command-line tool (similar to wget) that allows you to send and receive files over HTTP and FTP.

How do I enable cURL in PHP?

cURL is enabled by default but in case you have disabled it, follow the steps to enable it..
Open php. ini (it's usually in /etc/ or in php folder on the server)..
Search for extension=php_curl. dll. Uncomment it by removing the semi-colon( ; ) in front of it..
Restart the Apache Server..