从用户输入创建php文件

从用户输入创建php文件,php,Php,我需要使用以下代码从用户输入创建php文件来创建php文件 <?php $my_file = 'newfile.php'; $handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); ?> 上面的代码创建了新的php文件,但我需要创建包含一些内容的文件 例如,我有两个输入 <input type="file" name="cover"> <input type=

我需要使用以下代码从用户输入创建
php
文件来创建php文件

<?php
    $my_file = 'newfile.php';
    $handle = fopen($my_file, 'w') or die('Cannot open file:  '.$my_file); 
?>

上面的代码创建了新的php文件,但我需要创建包含一些内容的文件

例如,我有两个输入

<input type="file" name="cover">
<input type="text" name="body">


php文件应包含上述输入

您必须使用
fwrite
写入文件。请尝试以下代码

fwrite($handle, 'Content form input 1');
fwrite($handle, 'content from input 2');
fclose($handle);

您尝试了什么,在哪里失败了?请在代码中添加一些说明。它将比一些代码更好地帮助用户。
another example for create file:
  i have a folder names files where saved my creating my files and file ext = .txt 
 $fh = fopen("$files/{$id}.txt","w");
  fwrite($fh,$_POST['description']);//description is my field name where write something and send via post method
   fcolse($fh)