ultraloveninja Posted September 30, 2008 Share Posted September 30, 2008 Ok, so I've been trying to find what I need and I have not really been able to come across anything that looks like it does the trick. I am looking to write out and HTML file based on what gets parsed out by the PHP page. For example, the PHP page redenders out a table of information, and if I go to view source, it will show all of the HTML that has been written out by the PHP page. My question is how do I take the HTML that is written out by the PHP page and create a HTML file? I've seen some things with fopen and fwrite, but it's not writing out anything: <?php $my_file = "index.php"; $end_file = "test_index.html"; $fh = fopen($my_file,'r') or die("can't open file"); fwrite($fh, $end_file); echo "File succesfully written"; ?> Am I on the right track??? Quote Link to comment https://forums.phpfreaks.com/topic/126508-write-out-html-from-php/ Share on other sites More sharing options...
sKunKbad Posted September 30, 2008 Share Posted September 30, 2008 you will need to use fread instead of fwrite, and then just echo what was fread. Quote Link to comment https://forums.phpfreaks.com/topic/126508-write-out-html-from-php/#findComment-654209 Share on other sites More sharing options...
ultraloveninja Posted September 30, 2008 Author Share Posted September 30, 2008 Like this: <?php $my_file = "index.php"; $end_file = "test_index.html"; $fh = fopen($my_file,'r') or die("can't open file"); fread($fh, echo $end_file); echo "File succesfully written"; ?> Sorry, still pretty green to syntax formatting and what not. Quote Link to comment https://forums.phpfreaks.com/topic/126508-write-out-html-from-php/#findComment-654220 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.