加载XML数据时的警告

阿罗克·贾恩(Alok Jain)

我正在使用以下代码来获取洛杉矶的当前时间(小时)

$response_xml_data = file_get_contents('http://www.earthtools.org/timezone-1.1/34.05223/-118.24368');
$data = simplexml_load_string($response_xml_data);
$dt = new DateTime($data->localtime);
$time = $dt->format('H:i:s');
list($hour, $min, $sec) = explode(':', $time);
echo $hour;

这段代码可以在离线状态下正常工作,但是当我将此文件放到网上时,我收到以下警告消息:

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in [PHP file name and line number]

Warning: file_get_contents(http://www.earthtools.org/timezone-1.1/34.05223/-118.24368)
[function.file-get-contents]: failed to open stream: no suitable wrapper could be found in [PHP file name and line number]

看来我使用了错误的方法来读取XML数据,请提出建议吗?

卑鄙的

这意味着在您称为“在线”的服务器上,HTTP包装器已禁用PHP中的文件功能。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章