cURL后请求脚本给出“;未定义函数curl_init”;


cURL post request script giving "undefined function curl_init"

致命错误:在第9行调用C:''examplep''htdocs''lol.php中未定义的函数curl_init()

基本上这不起作用,我不知道它出了什么问题,POST请求中的所有字段都是正确的(作为一个对URL进行操作的HTML帖子表单,它非常有效)。

脚本:

<?php
$url = 'myurl';
$postData = array();
$postData['name'] = 'jay'
$postData['age'] = '0';
$postData['gender'] ='female';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$result = curl_exec($ch);
curl_close($ch);
?>

您的代码在$postData['name'] = 'jay' 中显示语法错误

 $postData = array();
 $postData['name'] = 'jay';
 $postData['age'] = '0';
 $postData['gender'] ='female';

以确保您是否已启用卷曲。只需将其放在php文件中,并在实例中找到启用了curl扩展名即可。

 <?php phpinfo();?>

在windows中启用curl examplep:如何在examplep中启用curr?