替代file_get_contents? [英] Alternative to file_get_contents?
本文介绍了替代file_get_contents?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$xml_file = file_get_contents(SITE_PATH . 'cms/data.php');
问题是服务器禁用了URL文件访问.我无法启用它,这是一个托管的东西.
The problem is that a server has URL file-access disabled. I cannot enable it, its a hosting thing.
所以问题是这样的. data.php
文件生成xml代码.
So the question is this. The data.php
file generates xml code.
如何执行此操作并获取xml数据,而无需执行上述方法?
How can I execute this and get the xml data without doing the above method?
有可能吗?
推荐答案
使用 cURL .此功能是file_get_contents
的替代方法.
Use cURL. This function is an alternative to file_get_contents
.
function url_get_contents ($Url) {
if (!function_exists('curl_init')){
die('CURL is not installed!');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
这篇关于替代file_get_contents?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文