March 26, 2012
How to get the rendered PHP+HTML codes into a text file?
Question by Leo Chan
Answer by Starx
Update:
It seems OP is asking about HOW to get the rendered PHP+HTML codes into a text file?
//get the output from the file
ob_start();
include "yourphpplushtml.php";
$output = ob_get_clean();
//now create a text file and write to it
$fp = fopen('data.txt', 'w+');
fwrite($fp, $output); //put the output
fclose($fp); //close the handler
//Or put it into the textare
echo '<textarea>'.$output.'</textarea>';
Previous Answer But may be helpful to others too
There are many ways HTML can be combined with PHP
-
Output HTML directly from PHP
<?php echo "<head><title>my new title</title></head>"; ?>
-
Include PHP inside you HTML
<title><?php echo $dynamictitle; ?></title>
-
Or even separate them in old fashioned complicated way
<?php if($resultFound == true) { ?> <p> The result was successfully found.</p> <?php } ?>