大家好,我想使用 cURL 将 $_POST 发送到另一台服务器,但我收到致命错误 调用未定义的函数 curl() im 缺少什么?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);
function curl($arra) {
{
您必须删除一个额外的大括号,也没有Test()
方法。