0

I have several old websites that use no php other than simple include lines like this:

<? include_once "includes/header.php"; ?>

Is there any way I can batch convert them over to HTML files so they contain the included content?

I'm hoping to host them as static files.

1
  • 2
    copy paste the content of that file where that line is Commented Oct 3, 2017 at 2:39

3 Answers 3

1

You could try opening the main PHP file in command line (instead of HTTP request) and outputing to a file.

php main.php > main.html
Sign up to request clarification or add additional context in comments.

Comments

1

I pieced together the following which finds all the php files and converts them to html:

find . -iname "*.php" -print | while read filename; do php $filename > "${filename%.*}".html ; done

Breakdown:

This finds all the php files in the current directory & child directories:

find . -iname "*.php" -print

This grabs the filename:

| while read filename;

This uses PHP to convert the files found to html:

do php $filename > "${filename%.*}".html ; done

Comments

0

If you have access to command line and PHP is installed on your machine you can use the following command the HTML files automatically (without copy/pasting).

$ php file.php > file.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.