如何从网上获取文件的内容?

时间:2018-02-12 13:25:31

标签: php http

我的编码是这样的

$xml=http_get('https://vnexpress.net/rss/khoa-học.rss');

但它有错误

Fatal error: Uncaught Error: Call to undefined function http_get() in C:\Apache24\htdocs\abc.php:22 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\abc.php on line 22

我还编码了

$doc=DOMDocument::load('https://vnexpress.net/rss/khoa-hoc.rss');

错误

Warning: DOMDocument::load(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in C:\Apache24\htdocs\abc.php on line 17

Warning: DOMDocument::load(): I/O warning : failed to load external entity "https://vnexpress.net/rss/khoa-hoc.rss" in C:\Apache24\htdocs\abc.php on line 17

感谢阅读。

1 个答案:

答案 0 :(得分:0)

您可以使用"的file_get_contents"像这样的方法:

$test = file_get_contents('https://vnexpress.net/rss/khoa-hoc.rss');
echo $test;