php file_get_contents()显示页面而不是HTML源代码 [英] php file_get_contents() shows page instead of html source code
本文介绍了php file_get_contents()显示页面而不是HTML源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I've got this piece of code, which should fetch the source code of the website.
我有这段代码,应该读取网站的源代码。 ( 'http://homepage.com');
echo $ homepage;
$homepage = file_get_contents('http://homepage.com');
echo $homepage;
而不是实际给我的源代码。它显示我正在尝试的页面获取源代码。
Instead of actually giving me the source code.. It's shows me the page that I'm trying to get the source code from.
推荐答案
使用 htmlentities
或更改内容类型。
$homepage = file_get_contents('http://homepage.com');
echo htmlentities($homepage);
或
header('Content-type: text/plain');
$homepage = file_get_contents('http://homepage.com/');
echo $homepage;
这篇关于php file_get_contents()显示页面而不是HTML源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文