卷曲错误:无法解析主机:www.localhost

时间:2018-09-18 09:19:23

标签: php curl

我收到一个错误,无法解决host:www.localhost。我不知道为什么会这样。

$url ="http://www.localhost:81/dbWIP/selectApi.php?name=".$name;
$client = curl_init();
echo $client;
curl_setopt($client, CURLOPT_URL,$url);
curl_setopt($client,CURLOPT_RETURNTRANSFER,true);
curl_setopt($client, CURLOPT_HEADER, false);
$response = curl_exec($client);
curl_close($client);
echo $response
$result = json_decode($response);

1 个答案:

答案 0 :(得分:2)

删除网址中的www.

$url ="http://localhost:81/dbWIP/selectApi.php?name=".$name;
$client = curl_init();
echo $client;
curl_setopt($client, CURLOPT_URL,$url);
curl_setopt($client,CURLOPT_RETURNTRANSFER,true);
curl_setopt($client, CURLOPT_HEADER, false);
$response = curl_exec($client);
curl_close($client);
echo $response
$result = json_decode($response);

并验证您的端口号81

netstat -a -b

这告诉您端口81绑定了什么程序