大家好我想使用cURL将$ _POST发送到另一台服务器,但我得到一个致命错误调用未定义的函数curl()我缺少什么? PS:我已经有一个php文件,它在同一台服务器上运行cURL,所以我确定服务器配置为使用cURL。
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
set_time_limit(0);
$status = json_decode(curl($_POST), true); // Here is the error line
}
function curl($arra) {
{
$ip = getenv("REMOTE_ADDR");
$arra['ip'] = $ip;
$ckfile = tempnam("./tmp", "CURLCOOKIE");
$ch = curl_init("site.com/file.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $arra);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$c = curl_exec($ch);
curl_close($ch);
return $c;
}
$ip = getenv("REMOTE_ADDR");
$hostname = gethostbyaddr($ip);
$details = simplexml_load_file("www.geoplugin.net/xml.gp?ip=" . $ip . "");
$codecountry = $details->geoplugin_countryCode;
$countryname = $details->geoplugin_countryName;
$codecountry2 = strtolower($codecountry);
这是错误的行
$status = json_decode(curl($_POST), true);
答案 0 :(得分:0)
testimonial-wrapper
您必须删除一个额外的花括号,也没有function curl($arra) {
{
方法。