且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用户在php中创建一个html文件

更新时间:2023-11-30 13:03:58

这样的代码如何:

  $ fh = fopen($ filename,'w')或死(无法打开文件); 
fwrite($ fh,'< html>< body>');
fwrite($ fh,< h1> $ title< / h1> $ text);
fwrite($ fh,'< / body>< / html>');
fclose($ fh);

其中文件名,标题和文本都填充了某些表单数据,或者从文件中读取。 p>

我希望这是你的意思。


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

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.