Leo Chan
Leo Chan

Reputation: 4427

How to get the rendered PHP+HTML codes into a text file?

I have a file which is combination of PHP and HTML.

How can i get the plain HTML code output from this file into a text file? or either put it into the text box.

The code of my form, which i use to generate an HTML form can be found here

Upvotes: 1

Views: 794

Answers (1)

Starx
Starx

Reputation: 79069

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

  1. Output HTML directly from PHP

    <?php
       echo "<head><title>my new title</title></head>";
    ?>
    
  2. Include PHP inside you HTML

    <title><?php echo $dynamictitle; ?></title>
    
  3. Or even separate them in old fashioned complicated way

    <?php if($resultFound == true) { ?>
        <p> The result was successfully found.</p>
    <?php } ?>
    

Upvotes: 2

Related Questions