本文介绍了卷曲错误:无法解析主机:www.localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I get an error could not resolve host:www.localhost. I don't know why it is coming.

$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);


推荐答案

删除 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的程序是什么

that's tell you what program is bound to port 81

这篇关于卷曲错误:无法解析主机:www.localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 15:32