Home  >  Article  >  Backend Development  >  PHP Curl function cannot be used in win7 (X64) system environment_PHP tutorial

PHP Curl function cannot be used in win7 (X64) system environment_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:43:29951browse

Curl function is a component that is not enabled by default in php. If you need to use Curl, we need to remove the ";" in front of extension=php_curl.dll in php.ini.

I first removed the ; in front of extension=php_curl.dll in php.ini and restarted the apache environment, but when calling the following function, it prompted

3. Restart the wamp service.
The code is as follows
 代码如下 复制代码

// 初始化一个cURL对象
$curl = curl_init();
// 设置您需要抓取的URL
curl_setopt($curl, CURLOPT_URL, 'http://www.bKjia.c0m'');
// 设置header
curl_setopt($curl, CURLOPT_HEADER, 1);
// 设置cURL参数,要求结果保存到字符串中还是输出到屏幕上
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// 运行cURL,请求网页
$data = curl_exec($curl);
// 关闭URL请求
curl_close($curl);
// 显示获得的数据
var_dump($data);
?>

Copy code

//Initialize a cURL object
$curl = curl_init();
//Set the URL you need to crawl
curl_setopt($curl, CURLOPT_URL, 'http://www.bKjia.c0m'');
//Set header
curl_setopt($curl, CURLOPT_HEADER, 1);
//Set cURL parameters to require the results to be saved in a string or output to the screen
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Run cURL to request the web page
$data = curl_exec($curl);
// Close URL request
curl_close($curl);
//Display the obtained data
var_dump($data);
?>

Error message

Call to undefined function curl_init()

After reading related articles, I copied the three files in PHP's ext directory: php_curl.dll, libeay32.dll and ssleay32.dll to the system system32 directory, but it still didn't work, so I connected to google and found win7 ( x64) There is one difference. The built-in php_curl.dll file does not work in the 64-bit windows7 environment

Specific solution steps:

1. Click the wamp icon in the notification bar, find the php_curl option in php-ext, click to select, and wait for the wamp restart service to complete.

2. Download the repaired php_curl.dll (php5.X/X64-bit system) file and place it in the wampbinphpphp (version number) ext folder.
Tips

After searching for so long, it turns out that the PHP environment we installed is different from the system version. It is best for us to choose the PHP version with the number of bits for the system. http://www.bkjia.com/PHPjc/633173.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/633173.html
TechArticle
Curl function is a component that is not enabled by default in php. If you need to use Curl, we need to set it in php.ini Just remove the ; in front of extension=php_curl.dll. I first changed the ext... in php.ini
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn