Check CURL is available using PHP

If you need to check whether curl is available in a web server, you can use snippet below to check available curl. The code below will check if curl is available and enabled in the web server.
PHP
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
<?php function iscurlinstalled() { if (in_array ('curl', get_loaded_extensions())) { return true; } else{ return false; } } ?>
Usage :
PHP
  • 1
  • 2
  • 3
<?php echo (iscurlinstalled())?'curl found':'no curl found'; ?>