$ch = curl_init('localhost/beater');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
//curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 3); //timeout in seconds
header('Content-Type: application/json');
echo curl_exec($ch);
// Check if any error occurred
if(curl_errno($ch))
{
echo curl_errno($ch);
//header('Location: error');
}
正如标题所说,我不是每次都设置域名,而是如何输入PHP文件? (因为它在我的域名上)。
如果我将其设置为$ch = curl_init('beater');
或$ch = curl_init('beater.php');
,我只会收到“错误3”,这是一个格式错误的网址
我希望你们能帮忙!