我想从php文件生成一个静态html页面,并从另一个php脚本中保存它.该脚本运行一堆回声功能,当在浏览器中查看是一个不错的html页面.但是当我运行file_get_contents时,它会将该文件作为文件系统上的文件打开,而不是作为URL中的文件.
我需要以localhost / site / categories.php方式调用file_get_contents吗?我该如何获得这条路?这是错误的代码:
<?php $file = file_get_contents("categories.php"); file_put_contents("categories.html",$file); ?>
要获得完成的输出,您需要使用PHP网址包装器功能,并通过Web服务器进行请求.那么这么简单:
copy("http://localhost/site/categories.php","categories.html");