Uncaught error call to undefined function curl init

This is a common error that occurs whenever PHP's curl extension has not been installed or enabled.

This error will occur if your server does not have PHP’s curl extension installed or enabled.

The error will read something like this.

Uncaught error: Call to undefined function curl_init()

Essentially, PHP can’t find the curl_init function because the extension that defines it has not been loaded. This results in a fatal error, which kills the PHP script.

To avoid this kind of error, you can check to see whether the cURL module has been loaded or not before you attempt to use it.

Check to see if curl is enabled.

To see if your PHP installation has cURL enabled, you can run the following piece of code.

<?php
//Call the phpinfo function.
phpinfo();

The phpinfo function above will output information about PHP’s configuration.

If a CTRL + F search for “curl” is unable to find anything, then it means that your web server has not loaded the curl extension.

If you do find it, then you should see the following line under the cURL heading:

cURL support: enabled

Note that you should NOT leave this phpinfo function on a live web server, as it outputs sensitive information about your PHP installation!

Enabling curl on Linux.

If your web server is running on Linux and you have SSH / terminal access, then you can install and enable cURL by running the following command.

sudo apt-get install php-curl

After running the command above, you will need to restart your web server so that the changes will take effect.

If you are using Apache, you can restart your web server like so.

sudo /etc/init.d/apache2 restart

If you are using Nginx, you can use the following command.

sudo /etc/init.d/nginx restart

After your web server has been restarted, curl should be available.

Enabling curl on Windows.

If you are using Windows, you will need to locate the php.ini file that is being used by your web server.

If you are unsure about which php.ini file you need to edit, then you can use the phpinfo script that we used above, as that will display the full path to the file that is being used by the web server.

Once you have located your php.ini file, you will need to “uncomment” the following line.

;extension=php_curl.dll

To uncomment the line above and enable the php_curl.dll extension, simply remove the semi-colon at the beginning.

After you have saved the changes that you made to your php.ini file,  you will need to restart your web server. Otherwise, the new configuration will not take effect.

Enabling curl on WampServer.

If you are using the popular WampServer program on Windows, then you can try the following steps:

  1. Click on the WampServer icon in your system tray.
  2. Hover over the “PHP” option.
  3. Once the PHP menu appears, hover over the “PHP extensions” option.
  4. At this stage, a list of PHP extensions should appear. If an extension has a tick beside it, then it is already enabled. If the php_curl option does not have a tick beside it, then it is not enabled. To enable curl, simply click on the php_curl option.
  5. WampServer should automatically restart Apache and the changes should take effect.
  6. If WampServer does not automatically restart Apache, then you can manually force it to do so by clicking on the “Restart All Services” option in the main menu.

Hopefully, this guide helped you to get rid of that nasty “undefined function curl_init” error!

Related: Sending a POST request without cURL.

Содержание

  1. Fixing “Uncaught error: Call to undefined function curl_init”
  2. Check to see if curl is enabled.
  3. Enabling curl on Linux.
  4. Enabling curl on Windows.
  5. Enabling curl on WampServer.
  6. PHP Fatal error: Uncaught Error: Call to undefined function curl_init()
  7. Shared Hosting
  8. Install cURL extension for Apache/Nginx on Linux
  9. Check php.ini
  10. Windows
  11. 4 replies
  12. Leave a reply
  13. Fatal error: Call to undefined function curl_init()
  14. Исправление ошибки “Fatal error: Call to undefined function curl_init()”
  15. Читайте также похожие статьи:
  16. PHP Fatal error: Uncaught Error: Call to undefined function curl_init()
  17. Shared Hosting
  18. Install cURL extension for Apache/Nginx on Linux
  19. Check php.ini
  20. Windows
  21. 4 replies
  22. Leave a reply

Fixing “Uncaught error: Call to undefined function curl_init”

This error will occur if your server does not have PHP’s curl extension installed or enabled.

The error will read something like this.

Uncaught error: Call to undefined function curl_init()

Essentially, PHP can’t find the curl_init function because the extension that defines it has not been loaded. This results in a fatal error, which kills the PHP script.

To avoid this kind of error, you can check to see whether the cURL module has been loaded or not before you attempt to use it.

Check to see if curl is enabled.

To see if your PHP installation has cURL enabled, you can run the following piece of code.

The phpinfo function above will output information about PHP’s configuration.

If a CTRL + F search for “curl” is unable to find anything, then it means that your web server has not loaded the curl extension.

If you do find it, then you should see the following line under the cURL heading:

Note that you should NOT leave this phpinfo function on a live web server, as it outputs sensitive information about your PHP installation!

Enabling curl on Linux.

If your web server is running on Linux and you have SSH / terminal access, then you can install and enable cURL by running the following command.

After running the command above, you will need to restart your web server so that the changes will take effect.

If you are using Apache, you can restart your web server like so.

If you are using Nginx, you can use the following command.

After your web server has been restarted, curl should be available.

Enabling curl on Windows.

If you are using Windows, you will need to locate the php.ini file that is being used by your web server.

If you are unsure about which php.ini file you need to edit, then you can use the phpinfo script that we used above, as that will display the full path to the file that is being used by the web server.

Once you have located your php.ini file, you will need to “uncomment” the following line.

To uncomment the line above and enable the php_curl.dll extension, simply remove the semi-colon at the beginning.

After you have saved the changes that you made to your php.ini file, you will need to restart your web server. Otherwise, the new configuration will not take effect.

Enabling curl on WampServer.

If you are using the popular WampServer program on Windows, then you can try the following steps:

  1. Click on the WampServer icon in your system tray.
  2. Hover over the “PHP” option.
  3. Once the PHP menu appears, hover over the “PHP extensions” option.
  4. At this stage, a list of PHP extensions should appear. If an extension has a tick beside it, then it is already enabled. If the php_curl option does not have a tick beside it, then it is not enabled. To enable curl, simply click on the php_curl option.
  5. WampServer should automatically restart Apache and the changes should take effect.
  6. If WampServer does not automatically restart Apache, then you can manually force it to do so by clicking on the “Restart All Services” option in the main menu.

Hopefully, this guide helped you to get rid of that nasty “undefined function curl_init” error!

Источник

PHP Fatal error: Uncaught Error: Call to undefined function curl_init()

cURL is a PHP extension used to transfer data to or from a remote server. If the extension is not installed or enabled on your web server, you may get a fatal PHP error about an undefined function curl_init().

If you are on shared hosting and do not have command line access to your web server or access to php.ini, you may have to contact your web host to see if they support the cURL PHP extension. Many web hosts disable this extension by default for security reasons but may enable it manually for you on request.

Install cURL extension for Apache/Nginx on Linux

If you have shell access to your Apache or Nginx web server, make sure the cURL extension is installed:

You must also restart your web server for changes to take effect.

To restart Apache, run:

To restart Nginx, run:

Now test cURL with:

If you see some HTML, cURL is working correctly.

Check php.ini

If cURL is installed but you are still getting “Call to undefined function curl_init()”, you may need to enable the extension in your php.ini file.

In the example below, we are editing the php.ini file for Apache with PHP 7.2.

Press CTRL + W and search for curl .

Remove the ; semicolon from the beginning of the following line. This line may look different depending on your version of PHP, just remove the semicolon.

To save file and exit, press CTRL + X , press Y and then press ENTER .

You must restart your web server for changes to take effect.

To restart Apache, run:

To restart Nginx, run:

Now test cURL with:

If you see some HTML, cURL is working correctly.

Windows

If you’re on Windows, go to your php.ini file and search for “curl”.

Remove the ; semicolon from the beginning of the following line.

If you are on an older version of PHP, the line might look like below.

After you have saved the file you must restart your HTTP server software before this can take effect.

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

p.s. I increased my AdSense revenue by 200% using AI 🤖. Read my Ezoic review to find out how.

Leave a reply

this works for me.:
sudo apt-get install php-curl

Источник

Fatal error: Call to undefined function curl_init()

Здравствуй уважаемый читатель блога LifeExample, у тебя бывало такое, когда знаешь, что код должен работать, но вместо ожидаемого результата компилятор говорит об обнаруженной фатальной ошибке? Я уверен, что бывало, так вот сегодня мне пришлось потратить не мало времени на устранение ошибки такого содержания Fatal error: Call to undefined function curl_init() , которое гласит о том, что функция curl_init() неизвестна компилятору, и нигде не определенна. Такая ошибка вызвала небольшое удивление, ибо код скрипта в котором содержится вызов curl_init() использовался мной на других хостингах без проблем, что позволило мне предположить о не правильности настроек файла php.ini.

Стоит отметить, что локальный хостинг на котором проявилась данная ошибка, организован с помощью набора дистрибутивов Denwer, достаточно популярном инструменте, начинающих веб разработчиков.

Первая самостоятельная попытка решения проблемы Fatal error: Call to undefined function curl_init() не увенчалась успехом. Первым действием был анализ файла php.ini , найдя в котором закомментированную строку:

я был уверен, что в этом кроется загвоздка. Удалив в начале строки точку с запятой “;”, и попробовав обновить страницу скрипта, снова получил сообщение об ошибке. Вновь принялся за изучения php.ini и нашел еще одну интересную строку:

Cодержание, которой говорит php компилятору, о том, в какой директории лежат все подключаемые dll библиотеки. Перейдя в директорию с удивлением обнаружил, отсутствие необходимого файла php_curl.dll. Поискав по просторам интернета, все таки нашел отсутствующую библиотеку php_curl.dll и загрузил ее в /usr/local/php5/ext . Как ни странно, но результата это не дало, вновь пришлось лицезреть сообщение: Fatal error: Call to undefined function curl_init().

Перечитав кучу форумов стал опускать руки, и уже хотел без помощи денвера самостоятельно поднять связку Apache, PHP и MySQL , дабы иметь полноценный комплект dll библиотек, включая и необходимую php_curl.dll , к счастью мне вовремя подвернулась правильная последовательность выполнения действий для решения данной задачи.

Исправление ошибки “Fatal error: Call to undefined function curl_init()”

  1. Скачиваем пакет библиотек для расширения возможностей набора denwer.
  2. Запускаем скачанный архив, в процессе установки он самостоятельно добавит нужную php_curl.dll , а также другие отсутствующие библиотеки.
  3. Открываем директорию, в которую установлен denwer, а именно каталог с данными PHP. Обычно это директория: c:WebServersusrlocalphp5.
  4. Копируем из данной директории файлы ssleay32.dll и libeay32.dll , вставляем их в каталог C:WINNTSYSTEM32.
  5. Открываем файл C:WebServersusrlocalphp5php.ini находим в нём строку “;extension=php_curl.dll”, и убираем точку с запятой вначале. (Внимание! Если ты до установки расширений из пункта №1 , уже проделывал данную операцию, не поленись вновь это повторить, ибо при установки данного пакета, файл php.ini перезаписывается).
  6. Перезапускаем denwer.
  7. Радуемся работе всех необходимых функций!

Данная последовательность действий является оптимальной для решения подобной проблемы при использовании утилиты denwer. Если же вы столкнулись с Fatal error: Call to undefined function curl_init(), не спользуя денвер, то вам следует покапаться в настройках php.ini , и вероятнее всего обратиться с своему хостинг-провайдеру.

Читайте также похожие статьи:

Чтобы не пропустить публикацию следующей статьи подписывайтесь на рассылку по E-mail или RSS ленту блога.

Источник

PHP Fatal error: Uncaught Error: Call to undefined function curl_init()

cURL is a PHP extension used to transfer data to or from a remote server. If the extension is not installed or enabled on your web server, you may get a fatal PHP error about an undefined function curl_init().

If you are on shared hosting and do not have command line access to your web server or access to php.ini, you may have to contact your web host to see if they support the cURL PHP extension. Many web hosts disable this extension by default for security reasons but may enable it manually for you on request.

Install cURL extension for Apache/Nginx on Linux

If you have shell access to your Apache or Nginx web server, make sure the cURL extension is installed:

You must also restart your web server for changes to take effect.

To restart Apache, run:

To restart Nginx, run:

Now test cURL with:

If you see some HTML, cURL is working correctly.

Check php.ini

If cURL is installed but you are still getting “Call to undefined function curl_init()”, you may need to enable the extension in your php.ini file.

In the example below, we are editing the php.ini file for Apache with PHP 7.2.

Press CTRL + W and search for curl .

Remove the ; semicolon from the beginning of the following line. This line may look different depending on your version of PHP, just remove the semicolon.

To save file and exit, press CTRL + X , press Y and then press ENTER .

You must restart your web server for changes to take effect.

To restart Apache, run:

To restart Nginx, run:

Now test cURL with:

If you see some HTML, cURL is working correctly.

Windows

If you’re on Windows, go to your php.ini file and search for “curl”.

Remove the ; semicolon from the beginning of the following line.

If you are on an older version of PHP, the line might look like below.

After you have saved the file you must restart your HTTP server software before this can take effect.

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

p.s. I increased my AdSense revenue by 200% using AI 🤖. Read my Ezoic review to find out how.

Leave a reply

this works for me.:
sudo apt-get install php-curl

Источник

Last updated on November 7th, 2019 | 4 replies

cURL is a PHP extension used to transfer data to or from a remote server. If the extension is not installed or enabled on your web server, you may get a fatal PHP error about an undefined function curl_init().

Shared Hosting

If you are on shared hosting and do not have command line access to your web server or access to php.ini, you may have to contact your web host to see if they support the cURL PHP extension. Many web hosts disable this extension by default for security reasons but may enable it manually for you on request.

Install cURL extension for Apache/Nginx on Linux

If you have shell access to your Apache or Nginx web server, make sure the cURL extension is installed:

sudo apt-get install php-curl

You must also restart your web server for changes to take effect.

To restart Apache, run:

sudo service apache2 restart

To restart Nginx, run:

sudo service nginx restart

Now test cURL with:

curl google.com

If you see some HTML, cURL is working correctly.

Check php.ini

If cURL is installed but you are still getting “Call to undefined function curl_init()”, you may need to enable the extension in your php.ini file.

Firstly, locate your php.ini file: Where is my PHP php.ini Configuration File Located?

In the example below, we are editing the php.ini file for Apache with PHP 7.2.

sudo nano /etc/php/7.2/apache2/php.ini

Press CTRL + W and search for curl.

Remove the ; semicolon from the beginning of the following line. This line may look different depending on your version of PHP, just remove the semicolon.

php.ini

;extension=curl

To save file and exit, press CTRL + X, press Y and then press ENTER.

You must restart your web server for changes to take effect.

To restart Apache, run:

sudo service apache2 restart

To restart Nginx, run:

sudo service nginx restart

Now test cURL with:

curl google.com

If you see some HTML, cURL is working correctly.

Windows

If you’re on Windows, go to your php.ini file and search for “curl”.

Remove the ; semicolon from the beginning of the following line.

php.ini

;extension=curl

If you are on an older version of PHP, the line might look like below.

php.ini

;extension=php_curl.dll

After you have saved the file you must restart your HTTP server software before this can take effect.

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

p.s. I increased my AdSense revenue by 200% using AI 🤖. Read my Ezoic review to find out how.

Понравилась статья? Поделить с друзьями:
  • Uncaught error call to a member function includecomponent on null in
  • Uncaught error call to a member function gettvvalue on null in
  • Uncaught error bootstrap s javascript requires jquery
  • Uncaught error addcase cannot be called with two reducers for the same action type
  • Uncaught error actions must be plain objects use custom middleware for async actions