hyp*_*not 15 php static get file
我想从php文件生成一个静态html页面,并将其保存在其他php脚本中.该脚本运行一堆echo函数,在浏览器中查看时是一个很好的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);
?>
Run Code Online (Sandbox Code Playgroud)
mar*_*rio 15
要获得完成的输出,您需要使用PHP url包装器功能并通过Web服务器请求它.然后它就像:
copy("http://localhost/site/categories.php", "categories.html");
Run Code Online (Sandbox Code Playgroud)
Bil*_*oon 11
是 - 以localhost方式运行file_get_contents - 如果您的服务器配置正确,它将不会跋涉到互联网并以有效的方式获得您的结果,即使托管在您自己的域名上也是如此.
<?php
$file = file_get_contents("http://yourserver.com/site/categories.php");
file_put_contents("categories.html", $file);
?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18056 次 |
| 最近记录: |