Atm*_*tma 5 php apache tomcat file-get-contents
我收到警告消息:file_get_contents无法打开流权限被拒绝
我在php.ini文件中将all_url_open设置为on.
我的php文件在我的apache服务器中,它试图从同一台机器上的tomcat服务器访问一个url(返回JSON).
php文件中的代码如下所示:
$srcURL = 'http://samemachine:8080/returnjson/';
$results = file_get_contents($srcURL);
Run Code Online (Sandbox Code Playgroud)
我也尝试过curl,它什么都不返回,也没有打到tomcat服务器:
function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Language: en-us'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
Run Code Online (Sandbox Code Playgroud)
为什么拒绝许可?
allow_url_fopen而不是all_url_open你写的phpinfo()。确保该选项列出为已启用。如果它没有重新启动您的网络服务器lo界面上观察