PHP 致命错误:调用未定义的函数 curl_init()
我在POST请求中尝试PHP Post Request,认为它可能对我有用。我的代码如下:
$sub_req_url = "http://localhost/index1.php";
$ch = curl_init($sub_req_url);
$encoded = '';
// include GET as well as POST variables; your needs may vary.
foreach($_GET as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
foreach($_POST as $name => $value) {
$encoded .= urlencode($name).'='.urlencode($value).'&';
}
// chop off last ampersand
$encoded = substr($encoded, 0, strlen($encoded)-1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_exec($ch);
curl_close($ch);
从该文件中,并且是同一目录中的另一个文件,当我打开页面时,我的文件中出现以下错误:index.php
index2.php
error.log
[Sat Dec 18 15:24:53 2010] [error] [client ::1] PHP Fatal error: Call to undefined function curl_init() in /var/www/testing1/index.php on line 5
我想做的是有一个预订表格来发送邮寄请求。然后,我想处理 post 值,并再次将 post 请求发送到PayPal。