[ACCEPTED]-Converting a .php file to a .html file?-html

Accepted answer
Score: 14

Here is a sample code:

<?php

ob_start();

// your PHP / HTML code here

file_put_contents('where/to/save/generated.html', ob_get_clean());

?>

0

Score: 4

Not sure if I understand the question right.
But 2 you can generate html files from php over 1 command line:

php index.php > index.html
Score: 2

Another option is to use apache's mod_rewrite 5 or the IIS equivelant to rewrite your URL's 4 from the browser perspective.

This would 3 require no coding change, make sure the 2 Apache extension is installed and add this 1 to the .htaccess file of your root web directory:

RewriteEngine on
RewriteBase /
RewriteRule ^([^/]*)\.html$ $1.php?%{QUERY_STRING} [NC]
Score: 1

you can use output buffering (ob_start, etc.) and 2 then write the content of the buffer to 1 a file at the end of your script

Score: 0

Is this (this) what you need?

If these are not options, you 2 can always curl to the page if it's running 1 on a web server/

Score: 0

It looks like you want to save a static 2 version of a dynamic web site. A tool like 1 WinHTTrack comes in handy.

More Related questions