curl_init -- ³õʼ»¯Ò»¸öCURL»á»°,Èç¹ûÌáʾCall to undefined function curl_initÄÇôÐèÒªÈçϲÙ×÷¼´¿É¡£
ÔÚÍøÉÏÏÂÔØÁËÒ»¸öÄ£ÄâµÇ½discuzÂÛ̳µÄphp³ÌÐò·¶Àý£¬ÊÔÔËÐÐʱ³öÏÖ¡°Call to undefined function curl_init¡±Õâ¸ö´íÎóÌáʾ£¬Ã»Óж¨ÒåµÄº¯Êý£¬Ò²¾ÍÊÇphp»¹Ã»´ò¿ª¶Ôcurl_initº¯ÊýµÄÖ§³Ö¡£GoogleÁËÒ»·¬ÖÕÓÚ½â¾öÁË£¬·½·¨ÈçÏ£º
ϵͳ»·¾³£¬WIN2003 IIS6£¬PHP°æ±¾5.2.12
ÔÚ×°ºÃPHPºó£¬Ö´ÐÐÀàËÆ$ch = curl_init();ÕâÑùµÄÓï¾ä£¬³öÏÖCall to undefined function curl_init()µÄ´íÎóÌáʾ¡£
½â¾ö·½·¨ÈçÏ£º
1¡¢ÔÚphp.iniÖÐÕÒµ½extension=php_curl.dll£¬È¥µôÇ°ÃæµÄ£¬php.iniÒ»°ãÔÚc:\windowsÏÂÃæ¡£
2¡¢ÔÚphp.iniÖÐÕÒµ½extension_dir = "ext"£¬È¥µôÇ°ÃæµÄ;£¬¸ÄΪextension_dir = "C:\php5\ext"¡£
"C:\php5\ext"Ö»ÊÇʾÀý£¬¼´À©Õ¹Ö¸ÏòµÄ·¾¶Òª¶Ô
3¡¢php_curl.dll¡¢libeay32.dll¡¢ssleay32.dll¡¢php5ts.dll¶¼¿½µ½system32ÏÂÃæÈ¥¡£
4¡¢È»ºóÖØÆôµçÄÔ£¬¹ÊÕϽâ¾ö¡£
×¢Ò⣺ÔÚPHPµÄ5.2.8°æ±¾Öв»ÖªµÀʲôÔÒò£¬ÓÃÕâ·½·¨ÎÞ·¨½â¾ö£¬»»³ÉÁË5.2.12²Å½â¾öµô¡£
ÒÔwindowsϵÄphp+apacheΪÀý¡£
¡¡¡¡Ê×ÏÈ£¬´ò¿ªphp.ini£¬ÕÒµ½¡°extension=php_curl.dll¡±£¬È»ºóÈ¥µôÇ°ÃæµÄ¡°;¡±×¢ÊÍ£¬ÖØÆôapache¼´¿É¡£
¡¡¡¡Èç¹û»¹³öÏÖ´ËÀàÎÊÌ⣬Ïȼì²éphp.iniµÄextension_dirÖµÊÇÄĸöĿ¼£¬ÔÚÄǸöĿ¼Ï¼ì²éÓÐÎÞphp_curl.dll£¬Ã»ÓеĻ°ÇëÏÂÔØphp_curl.dll£¬ÔÙ°ÑphpĿ¼ÖеÄlibeay32.dllºÍssleay32.dll¿½µ½c:\windows\system32ÀïÃ棬ÖØÆôapache£¬OK£¡
ÔÚUbuntu ÏÂÔËÐÐphp£¬×ÜÊÇÌáʾCall to undefined function curl_init()£¬ÔÒòûÓа²×ª£ºphp5-curl
ÓëcurlÏà¹ØµÄÄÚÈݼû£ºhttp://packages.ubuntu.com/zh-cn/intrepid/php5-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 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 -- ³õʼ»¯Ò»¸öCURL»á»°
ÃèÊö ¡¡
int curl_init ([string url]) ¡¡
curl_init()º¯Êý½«³õʼ»¯Ò»¸öеĻỰ£¬·µ»ØÒ»¸öCURL¾ä±ú¹©curl_setopt(), curl_exec(),ºÍ curl_close() º¯ÊýʹÓá£Èç¹û¿ÉÑ¡²ÎÊý±»Ìṩ£¬ÄÇôCURLOPT_URLÑ¡Ï±»ÉèÖóÉÕâ¸ö²ÎÊýµÄÖµ¡£Äã¿ÉÒÔʹÓÃcurl_setopt()º¯ÊýÈ˹¤ÉèÖá£
Àý 1. ³õʼ»¯Ò»¸öеÄCURL»á»°£¬ÇÒÈ¡»ØÒ»¸öÍøÒ³
<?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);
?>
²Î¼û£ºcurl_close(), curl_setopt()