3

I am trying to create a script that will get multiple HTML files that could have PHP code in them and JavaScript code and make a big HTML/PHP file with that. E.g home.php, news.php, something.php Will be combined to form Index.php.

Before anyone ask why I need a file like that: the reason is to create 1 file that uses responsible layout for touch-swipe using parallax.

I've tried file_get_contents() but if the html has a simple <?php echo "hello world";?> it wont output it.

How could I merge multiple HTML files with anything in them (JS, php, etc)?

2
  • 1
    Why you want to do that? Commented Jan 23, 2013 at 12:16
  • @shiplu.mokadd.im if you check most parallax scripts they work using IDs and all pages are in a single master page so that the swipe through pages is easier. Instead of creating a single big file.. its better to do each page on its own and then merge them together in the code into a big file. Commented Jan 23, 2013 at 12:20

2 Answers 2

2

If you want the unexecuted PHP code, you will require an FTP connection to the PHP files. Using cURL, you'll open an FTP connection and download the file, which will be in its original form with <?php echo "hello world"; ?> and such. This is just like using a normal FTP client in your operating system to retrieve the file, in this case it will be in a variable in your PHP script, then you can execute the contents or do whatever from there.

Of course this method is also dependent on whether the host (server) allows it.

Sign up to request clarification or add additional context in comments.

Comments

2

Have you tried a include()? That should work fine.

From the PHP docs... http://php.net/manual/en/function.include.php

The include statement includes and evaluates the specified file.

4 Comments

I've tried too but when I do var_dump() it shows the output of that and i want the unexecuted code
Can you clarify what you mean? In your question you said that "<?php echo "hello world";?> it wont output it." This makes me think you do want the code to be executed.
@Space_monkey I think the OP wants the text <?php echo "hello world";?> instead of just hello world.
You can't $cho = include('cached-site/issue-1/index.php'); for multiple files. it just include them to the page

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.