Solution for Call to undefined function curl_init() when php runs

curl_init -- Initialize a CURL session. If it prompts Call to undefined function curl_init, you need to do the following.

I downloaded an example of a php program that simulates landing on the discuz forum. The error message "Call to undefined function curl_init" appeared during the trial operation. There is no defined function, that is, PHP has not yet opened support for the curl_init function. Google has finally solved it, the method is as follows:

System environment, WIN2003 IIS6, PHP version 5.2.12
After installing PHP, execute a statement like $ch = curl_init();, an error message of Call to undefined function curl_init() appears.

The workaround is as follows:

1. Find extension=php_curl.dll in php.ini, remove the previous one, php.ini is generally under c:\windows.

2. Find extension_dir = "ext" in php.ini, remove the preceding ; and change it to extension_dir = "C:\php5\ext".
"C:\php5\ext" is just an example, that is, the path pointed to by the extension should be correct

3. php_curl.dll, libeay32.dll, ssleay32.dll, php5ts.dll are all copied to system32.

4. Then restart the computer, the fault is solved.

Note: I don't know the reason in the 5.2.8 version of PHP, it can't be solved by this method, and it can be solved by replacing it with 5.2.12.

Take php+apache under windows as an example.

  First, open php.ini, find "extension=php_curl.dll", then remove the preceding ";" comment, and restart apache.

  If this kind of problem still occurs, first check which directory the extension_dir value of php.ini is, and check whether there is php_curl.dll in that directory. If not, please download php_curl.dll, and then put libeay32.dll and ssleay32 in the php directory. dll is copied to c:\windows\system32, restart apache, OK!

When running php under Ubuntu, it always prompts Call to undefined function curl_init()

. curl

CURL is a library for getting files from FTP, GOPHER, HTTP server.

PHP5 is an HTML-embedded scripting language. Much of its syntax is borrowed from C, Java and Perl with a couple of unique PHP-specific features thrown in. The The goal of the language is to allow web developers to write dinamically generated pages quickly. This version of PHP5 was built with the Suhosin patch.

H1>

(PHP 4 >= 4.0.2)

curl_init -- initialize a CURL session

Description  

int curl_init ([string url])  

The curl_init() function will initialize a new session and return a CURL handle for curl_setopt(), curl_exec() , and the curl_close() function is used. If an optional parameter is provided, the CURLOPT_URL option will be set to the value of this parameter. You can manually set it using the curl_setopt() function.
Example 1. Initialize a new CURL session and retrieve a web page

<?php
$ch = curl_init();

curl_setopt ($ch, CURLOPT_URL, "http://www.zend.com/");
curl_setopt ($ch , CURLOPT_HEADER, 0);

curl_exec ($ch);

curl_close ($ch);
?>


see: curl_close(), curl_setopt()

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325596200&siteId=291194637