php file_get_contents() shows page instead of html source code

后端 未结 4 947
春和景丽
春和景丽 2021-01-03 09:42

I\'ve got this piece of code, which should fetch the source code of the website.

$homepage = file_get_contents(\'http://homepage.com\');
echo $homepage;
         


        
4条回答
  •  遥遥无期
    2021-01-03 10:41

    It's because you are printing the source, your browser will interpret that as a webpage. To see the actual code use:

    echo htmlspecialchars($homepage);
    

提交回复
热议问题