Jump to content

Create php file using php.


YourNameHere

Recommended Posts

Is it possible to create a .php file using PHP commands?

 

this is from tizag.com

 

[pre]$myFile = "testFile.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = "New Stuff 1\n";
fwrite($fh, $stringData);
$stringData = "New Stuff 2\n";
fwrite($fh, $stringData);
fclose($fh);
[/pre]

 

That creates a .txt file, it is possible to do, sometext.php? and echo or print variables in it?

Link to comment
Share on other sites

the reason I want to do it is I am making a administrative back-end to a site and would like to allow the admin to add pages to the site with a common layout template.

 

This is just my initial idea. If you have a better way, please enlighten me. :)

 

Perhaps you should instead have a common template that could be filled with content from database?

Link to comment
Share on other sites

Perhaps you should instead have a common template that could be filled with content from database?

 

That is in fact what I will be doing. However, how would that content have a unique URL other than get vars? I'd rather make a function  that creates a new script altogether. But if that is a poor design choice...

 

I guess I am probably misunderstanding what you mean.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.