关于PHP程序使用file_get_content()函数进行抓取PHP程序与smarty结合编译过程中产生的静态文件,抓取不了?连接超时?(地址映射)

问题:

当file_get_content()函数的参数  url中是localhost时不能抓取,是127.0.0.1时可以抓取到静态html代码。实现页面静态化技术提高访问效率。

test.php
<?php $html = file_get_contents("http://localhost/smarty002/jingtaihua.php"); //这里的jingtaihua.php是可以访问的 file_put_contents("jingtaihua.html", $html); ?>

解决方法:

修改host文件夹,映射IP地址

原文地址:https://www.cnblogs.com/wuyinghong/p/3333314.html