php file_get_contents() shows page instead of html source code

后端 未结 4 936
春和景丽
春和景丽 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:23

    Try this, using htmlspecialchars:

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

提交回复
热议问题