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
https://forums.phpfreaks.com/topic/190751-create-php-file-using-php/
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?

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.