I know the title sounds weird, but what I want is to create and store a page that uses php from a php script in another page. It must be possible, since I should be able to generate the whole page as a string and scape the " and $ characters, but I don't know how. Does anyone can give me the answer or point to a tutorial or search terms I could use? Thanks
You can open the PHP file in question as a string using file_get_contents(), the use fopen() to save the file out as a new file with an extension of your choice. For example:
<?php // Create a new file with fopen. $handle = fopen("new_text_file.txt", "w");
// Get the contents of the original file. $original_file = file_get_contents("original_file.txt", true);
// Write the new file based on the above. $write = fwrite($handle, $original_file); ?>
You'll need to create a .txt file in the same directory called "original_file" with some data inside it, such as "Hello World". Once the code runs, it'll copy the contents of that file and write it out as a new file.
You could always Base64 encode it and then decode it as you write it with fwrite().
(I know many of you don't like the idea of it, but it gets around many issues)
Hit me up with a PM if you'd like some help