PHP file_put_contents save from php file

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 07:14:33

Another way (doesn't need an http server nor access to shell):

<?php

ob_start();
include('index.php');
$page = ob_get_contents();
ob_end_clean();

file_put_contents('result.html', $page);

?>

You are simply copying php code into html file.

to get html source code you need to interpret php file

one way of doing this is:

file_put_contents('result.html', file_get_contents('http://localhost/path/to/index.php'));

Use this code

file_put_contents('result.html', file_get_contents('http://localhost/yourproject/index.php'));

You can try:

file_put_contents('result.html', shell_exec('php path/to/index.php'));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!