<p>For a particular project I have, no server side code is allowed. How can I create the web site in php (with includes, conditionals, etc) and then have that converted into a static html site that I can give to the client?</p>

<p>Update: Thanks to everyone who suggested wget. That's what I used. I should have specified that I was on a PC, so I grabbed the windows version from here: <a href="http://gnuwin32.sourceforge.net/packages/wget.htm" rel="noreferrer">http://gnuwin32.sourceforge.net/packages/wget.htm</a>.</p>

[{'answer_id': 66623, 'author': 'Peter Boughton', 'author_id': 9360, 'author_profile': 'https://Stackoverflow.com/users/9360', 'pm_score': 1, 'selected': False, 'text': '<p>Create the site as normal, then use spidering software to generate a HTML copy.</p>\n\n<p><a href="http://www.httrack.com/" rel="nofollow noreferrer">HTTrack</a> is software I have used before.</p>\n'}, {'answer_id': 66624, 'author': 'Paul Dixon', 'author_id': 6521, 'author_profile': 'https://Stackoverflow.com/users/6521', 'pm_score': 2, 'selected': False, 'text': '<p>build your site, then use a mirroring tool like <a href="http://www.gnu.org/software/wget/" rel="nofollow noreferrer">wget</a> or <a href="http://search.cpan.org/dist/libwww-perl/bin/lwp-mirror" rel="nofollow noreferrer">lwp-mirror</a> to grab a static copy</p>\n'}, {'answer_id': 66634, 'author': 'jamuraa', 'author_id': 9805, 'author_profile': 'https://Stackoverflow.com/users/9805', 'pm_score': 1, 'selected': False, 'text': '<p>One way to do this is to create the site in PHP as normal, and have a script actually grab the webpages (through HTTP - you can use wget or write another php script that just uses file() with URLs) and save them to the public website locations when you are "done".  Then you can just run the script again when you decide to change the pages again.  This method is quite useful when you have a slowly changing database and lots of traffic, as you can eliminate all SQL queries on the live site. </p>\n'}, {'answer_id': 66652, 'author': 'millenomi', 'author_id': 6061, 'author_profile': 'https://Stackoverflow.com/users/6061', 'pm_score': 0, 'selected': False, 'text': '<p>I do it on my own web site for certain pages that are guaranteed not to change -- I simply run a shell script that could be boiled to (warning: bash pseudocode):</p>\n\n<pre><code>find site_folder -name \\*.static.php -print -exec Staticize {} \\;\n</code></pre>\n\n<p>with Staticize being:</p>\n\n<pre><code># This replaces .static.php with .html\nTARGET_NAME="`dirname "$1"`/"`basename "$1" .static.php`".html\nphp "$1" &gt; "$TARGET_NAME"\n</code></pre>\n'}, {'answer_id': 66667, 'author': 'Jake McGraw', 'author_id': 302, 'author_profile': 'https://Stackoverflow.com/users/302', 'pm_score': 6, 'selected': True, 'text': '<p>If you have a Linux system available to you use <a href="http://www.gnu.org/software/wget/" rel="noreferrer">wget</a>:</p>\n\n<pre><code>wget -k -K  -E -r -l 10 -p -N -F -nH http://website.com/\n</code></pre>\n\n<p>Options</p>\n\n<ul>\n<li>-k : convert links to relative</li>\n<li>-K : keep an original versions of files without the conversions made by wget</li>\n<li>-E : rename html files to .html (if they don’t already have an htm(l) extension)</li>\n<li>-r : recursive… of course we want to make a recursive copy</li>\n<li>-l 10 : the maximum level of recursion. if you have a really big website you may need to put a higher number, but 10 levels should be enough.</li>\n<li>-p : download all necessary files for each page (css, js, images)</li>\n<li>-N : Turn on time-stamping.</li>\n<li>-F : When input is read from a file, force it to be treated as an HTML file.</li>\n<li>-nH : By default, wget put files in a directory named after the site’s hostname. This will disabled creating of those hostname directories and put everything in the current directory.</li>\n</ul>\n\n<p>Source: <a href="http://blog.jphoude.qc.ca/2007/10/16/creating-static-copy-of-a-dynamic-website/" rel="noreferrer">Jean-Pascal Houde\'s weblog</a></p>\n'}, {'answer_id': 66712, 'author': 'Raynet', 'author_id': 4294, 'author_profile': 'https://Stackoverflow.com/users/4294', 'pm_score': 2, 'selected': False, 'text': "<p>I have done this in the past by adding:</p>\n\n<pre><code>ob_start();\n</code></pre>\n\n<p>In the top of the pages and then in the footer:</p>\n\n<pre><code>$page_html = ob_get_contents();\nob_end_clean();\nfile_put_contents($path_where_to_save_files . $_SERVER['PHP_SELF'], $page_html);\n</code></pre>\n\n<p>You might want to convert .php extensions to .html before baking the HTML into the files.\nIf you need to generate multiple pages with variables one quite easy option is to append the filename with md5sum of all GET variables, you just need to change them in the HTML too. So you can convert:</p>\n\n<pre><code>somepage.php?var1=hello&amp;var2=hullo\n</code></pre>\n\n<p>to</p>\n\n<pre><code>somepage_e7537aacdbba8ad3ff309b3de1da69e1.html\n</code></pre>\n\n<p>ugly but works.</p>\n\n<p>Sometimes you can use PHP to generate javascript to emulate some features, but that cannot be automated very easily.</p>\n"}, {'answer_id': 66736, 'author': 'Erik I', 'author_id': 9987, 'author_profile': 'https://Stackoverflow.com/users/9987', 'pm_score': 1, 'selected': False, 'text': '<p>If you use modx it has a built in function to export static files.</p>\n'}, {'answer_id': 66799, 'author': 'nickf', 'author_id': 9021, 'author_profile': 'https://Stackoverflow.com/users/9021', 'pm_score': 1, 'selected': False, 'text': '<p>If you have a number of pages, with all sorts of request variables and whatnot, probably one of the spidering tools the other commenters have mentioned (wget, lwp-mirror, etc) would be the easiest and most robust solution.</p>\n\n<p>However, if the number of pages you need to get is low, or at least <em>manageable</em>, you\'ve got a few options which don\'t require any third party tools (not that you should discount them JUSt because they are third party).</p>\n\n<ol>\n<li><p>You can use php on the command line to get it to output directly into a file.</p>\n\n<p><code>php myFile.php &gt; myFile.html</code></p>\n\n<p>Using this method could get painful (though you could put it all into a shell script), and it doesn\'t allow you to pass variables in the same way (eg: <code>php myFile.php?abc=1</code> won\'t work).</p></li>\n<li><p>You could use another PHP file as a "build" script which contains a list of all the URLs you want and then grabs them via <code>file_get_contents()</code> or <code>file()</code> and writes them to a local file. Using this method, you can also get it to check if the file has changed (<code>md5_file()</code> should work for that), so you\'ll know what to give your client, should they only want updates.</p></li>\n<li><p>Further to #2, before you write the output to file, scan it for local urls and then add those to your list of files to download. While you\'re there, change those urls to link to what you\'ll eventually name your output so you have a functioning web at the end. Note of caution here - if this is sounding good, you could probably use one of the tools which already exist and do this for you.</p></li>\n</ol>\n'}, {'answer_id': 66932, 'author': 'Jordan Mack', 'author_id': 9979, 'author_profile': 'https://Stackoverflow.com/users/9979', 'pm_score': 0, 'selected': False, 'text': '<p>wget is probably the most complete method. If you don\'t have access to that, and you have a template based layout, you may want to look into using Savant 3. I recommend Savant 3 highly over other template systems like Smarty. </p>\n\n<p>Savant is very light weight and uses PHP as the template language, not some proprietary sublanguage. The command you would want to look up is fetch(), which will "compile" your template and place it in a variable that you can output.</p>\n\n<p><a href="http://www.phpsavant.com/" rel="nofollow noreferrer">http://www.phpsavant.com/</a></p>\n'}, {'answer_id': 67741, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>Alternatively to wget you could use (Win|Web)HTTrack (<a href="http://www.httrack.com/" rel="nofollow noreferrer">Website</a>) to grab the static page. HTTrack even corrects links to files and documents to match the static output.</p>\n'}, {'answer_id': 72988160, 'author': 'Michael L', 'author_id': 19553056, 'author_profile': 'https://Stackoverflow.com/users/19553056', 'pm_score': 1, 'selected': False, 'text': '<p>You can use python or visual basic (or your choice) to create your static files all at once then upload them.</p>\n<p>For a project with 11 million business listings in excel files I used VBA to extract the spreadsheet data into 11 mil small .php files, then zipped, ftp\'d, unzipped.</p>\n<p><a href="https://contactlookup.us" rel="nofollow noreferrer">https://contactlookup.us</a></p>\n<p>Voila - a super fast business directory</p>\n<p>I started with Jekyll, but after about half million entries the generator got bogged down. For 11 million it looked like it would finalize the build in about 2 months!</p>\n'}]
['https://Stackoverflow.com/questions/66610', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3741/']