Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP file_put_contents save from php file

I'm trying to get the Html source code from a php file and put it into an Html file using this:

file_put_contents('result.html', file_get_contents('index.php'));

After running this function, The "result.html" will contain the same PHP codes in the original "index.php" file, While I need "result.html" file to get the Html code after index.php has executed. Any Help Please?. Thanks.

like image 595
user2044626 Avatar asked Dec 03 '25 09:12

user2044626


1 Answers

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'));
like image 161
Ravikumar Sharma Avatar answered Dec 04 '25 22:12

Ravikumar Sharma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!