Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Curl错误:无法解析主机:www.localhost_Php_Curl - Fatal编程技术网

Php Curl错误:无法解析主机:www.localhost

Php Curl错误:无法解析主机:www.localhost,php,curl,Php,Curl,我收到一个错误,无法解析主机: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($clien

我收到一个错误,无法解析
主机: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);

删除url中的
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

它可能只是
http://localhost
。您尝试过不使用www吗?