Php 找不到本地主机服务器

Php 找不到本地主机服务器,php,Php,当我在本地主机上为file\u get\u contents($url)执行脚本时,它会持续加载几分钟,然后显示此错误: Server not found Firefox can't find the server at www.localhost.com. 有什么帮助吗?你的脚本在做什么?您的服务器(例如apache)启动了吗?您在firefox中启动了url吗 http://localhost/ ??看起来firefox正在寻找另一个域,而不是真正的本地主机 将此代码放入php文件(仅

当我在本地主机上为
file\u get\u contents($url)
执行脚本时,它会持续加载几分钟,然后显示此错误:

Server not found

Firefox can't find the server at www.localhost.com.

有什么帮助吗?

你的脚本在做什么?您的服务器(例如apache)启动了吗?您在firefox中启动了url吗

http://localhost/
??看起来firefox正在寻找另一个域,而不是真正的本地主机

将此代码放入php文件(仅此代码):


我的脚本执行
$html=file\u get\u html($url)对于剩余的脚本执行,它工作正常OK,$url变量内容是什么?如果删除这一行,整个脚本工作正常?$url包含有效的url名称,脚本的其余部分工作正常sureOk,但有效的url是什么?它是否以http://开头,是否为localhost?
echo$url
并告诉我们结果。您确定您的XAMPP(或您正在使用的任何东西)正在运行吗?您是否在
hosts
文件中设置了www.localhost.com的地址?如果不是,请使用
http://localhost
<?php

$url = 'http://www.yelp.com';

$output = file_get_contents($url);

var_dump($output);