Call to undefined function curl init()

From Php

Jump to: navigation, search

You can get errors that look like this

 Fatal error: Call to undefined function curl_init() in foo.php on line 61

if you do not have the curl package installed.

How to install php-curl:

  • If you are using PHP on someone else's computer, e.g., you have a hosting provider, you will need to ask them to install php-curl.
  • Under Ubuntu, install the package php4-curl or php5-curl with apt-get or synaptic, then restart apache.
  • Under Windows, php-curl can be enabled by uncommenting the curl extension line in the php.ini file (--extension=php_curl.dll) and restarting the web server. Note: not sure about the exact syntax, it might be only one dash.


Do not forget to restart your Web server.

You can see if you have curl installed by creating a file test.php

 <?php
 phpinfo();
 ?> 

On apache2 under Ubuntu, there is a table entry that looks like this:

additional .ini files parsed /etc/php5/apache2/conf.d/curl.ini, /etc/php5/apache2/conf.d/gd.ini, /etc/php5/apache2/conf.d/mysql.ini, /etc/php5/apache2/conf.d/mysqli.ini, /etc/php5/apache2/conf.d/pdo.ini, /etc/php5/apache2/conf.d/pdo_mysql.ini

Thanks to mab on programmingtalk.com for the reminder of phpinfo() and instructions for a Windows machine.