create a html file in php by user [closed]

2019-04-16 04:12发布

问题:

well I want to make a feature to my cms which user can make some static page by its orders , such

file name , Content , picture ....

for example , user can make an about us.. that file name is about.php , have a custom content in it , and all of these are given by a user in another php page

please recommend me to use which php function to make these , tnx

回答1:

How about some code like this:

$fh = fopen($filename, 'w') or die("can't open file");
fwrite($fh, '<html><body>');
fwrite($fh, "<h1>$title</h1>$text");
fwrite($fh, '</body></html>');
fclose($fh);

where filename, title and text are filled with some form data, or read from a file.

I hope this is what you meant.