我刚刚将一个项目从localhost移到我的远程服务器,并注意到我的一些脚本停止工作.最重要的是依赖于file_get_contents()从另一个脚本获取
JSON值.
PHP版本是5.2.4
allow_url_fopen为ON
Warning:
file_get_contents()[function.file-get-contents]:PHP_network_getaddresses:getaddrinfoFailed: Name or service not kNown in/var/www/html/2009/functions/functions.products.PHPonline 5Warning:
file_get_contents(http://data.example.com/new-data.PHP) [function.file-get-contents]: Failed to open stream:Success in /var/www/html/2009/functions/functions.products.PHPonline 5
脚本正在从http://www.example.com运行
传入该函数的位置是http://data.example.com/new-data.PHP
注意:相同的域名,但两个不同的服务器.
function getData() {
$location = "http://data.mysite.com/new-data.PHP";
$contents = file_get_contents($location);
$jsonVars = json_decode($contents);
return $jsonVars
}
Name or service not kNown
DNS破了你可以从机器上的shell(假设你有)ping data.mysite.com吗?
现在尝试用固定的IP地址替换data.mysite.com.