我刚刚将一个项目从localhost移到了我的远程服务器上,并注意到我的一些脚本停止了工作.最重要的是依赖于file_get_contents()
从另一个脚本获取JSON值的那个.
PHP版本是5.2.4
allow_url_fopen
是ON
警告:
file_get_contents()
[function.file-get-contents]
:php_network_getaddresses
:getaddrinfo
失败:产品名称或服务不知道/var/www/html/2009/functions/functions.products.php
的line 5
警告::
file_get_contents(http://data.example.com/new-data.php) [function.file-get-contents]
无法打开流:Success in /var/www/html/2009/functions/functions.products.php
打开line 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
}
Run Code Online (Sandbox Code Playgroud) php ×1