So I have this html template, and I would like PHP to look at this template, and make a new html page, that is a copy of this, and only change the name of the file. Basically: template.html -> PHP -> template-copy.html
I don't understand karlpcrowley's code use. That's just talking about filenames or so. I want to create a new file entirely, but that has the same content.
And I can give it read and write permissions. That's OK.
The PHP page itself can be an html template with variables that changed when parsed and sent to the browser, so why have PHP read a static file and change parts to write another file? Are you intending on keeping the copy and always making new copies?
How you scan and change the file will depend on what you are doing. You could use the strtr() function to translate variable code in the file to something else.
Could you explain what that does please? (and what is variable scanning?) I'm rather new to PHP, so I don't get what passing the variables to the functions makes them do.
if (!copy($file, $newfile)) { echo "failed to copy $file...\n"; }
With that, could I have a dialogue box that the customer could put in the name that they wanted? Say I have template.html and I add content to make it a blog. Then a window (or something) comes up and asks what I want to save it as. Then the modified template would become blog.html. Also, would there be any trouble viewing the new pages? Sorry if that made little sense. It's really late and I'm on my iPad.
Basically:
template.html -> PHP -> template-copy.html
And I can give it read and write permissions. That's OK.
Can I do this?
I then run a PHP script, that copies the template, giving the variables a different value each time (might this work with input/output?)
A new page is created, that has the same structure as the template, with only the variables changing.
The PHP page itself can be an html template with variables that changed when parsed and sent to the browser, so why have PHP read a static file and change parts to write another file? Are you intending on keeping the copy and always making new copies?
What you'll need to do is something like:
How you scan and change the file will depend on what you are doing. You could use the strtr() function to translate variable code in the file to something else.
Could you explain what that does please? (and what is variable scanning?)
I'm rather new to PHP, so I don't get what passing the variables to the functions makes them do.
$newfile = 'template-copy.html';
if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}
With that, could I have a dialogue box that the customer could put in the name that they wanted? Say I have template.html and I add content to make it a blog. Then a window (or something) comes up and asks what I want to save it as. Then the modified template would become blog.html. Also, would there be any trouble viewing the new pages? Sorry if that made little sense. It's really late and I'm on my iPad.