PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Thanks, I've managed to copy html from the first file to the second, but couldn't execute (?) PHP on it as I got its contents to be written on the new file.
Using fopen grabs the file contents as it is on the file system. If you want it pasring by php then you need to grab it via http (using curl or another method).
but you'll have trouble passing values to it as (I think) each word is treated as a seperate arguement within $argv[]. Probably easier to just go with the http method.
<?php
$inFile = 'html-in.php';
$outFile = 'html-out.html';
$htmlBody = '<p>Hello, World.</p>';
// Checks that the input file exists.
// Opens the output file for writing and truncates it to zero length.
if (file_exists($inFile) && ($fo = fopen($outFile, 'w'))) {
// Starts the output buffer.
ob_start();
// Reads and parses the input file like any other PHP script.
include $inFile;
// Writes the contents of the output buffer to the output file.
fwrite($fo, ob_get_contents());
// Flushes the ouput buffer so the contents are not displayed
// and turns off output buffering.
ob_end_clean();
// Closes the output file.
fclose($fo);
// Displays a link to the output file
echo '<a href="'.$outFile.'">'.$outFile.'</a>';
}
?>