1

Is it possible to combine multiple PHP files via the command line and create an HTML file?

For example, this will save the rendered version of a single PHP file as HTML:

php /path/to/my/file/filename.php > /path/to/my/file/test.html

I need it to combine multiple files, but I can't seem to get it it to work. Ideally, it would be something like this:

php /path/to/my/file/filename.php + /path/to/my/file/filename2.php + /path/to/my/file/filename3.php > /path/to/my/file/test.html

Is this possible? If so, how?

3 Answers 3

2

Maybe you could do:

php file.php > someFile.html
php file2.php >> someFile.html
php file3.php >> someFile.html
Sign up to request clarification or add additional context in comments.

Comments

1

You can use >> to append output in bash.

touch /path/to/my/file/test.html
php /path/to/my/file/filename.php >> /path/to/my/file/test.html
php /path/to/my/file/filename2.php >> /path/to/my/file/test.html

Comments

1

I think what you may be looking for is cat file1.php file2.php file3.php | php > file.html

1 Comment

possible problem with global variables

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.