<?php $title = $_POST['title']; $filename = $title , ".php"; $fh = fopen($filename, 'w') or die ("can't open file"); $stringData = $title; fwrite($fh, $stringData); $stringData = $blog; fwrite($fh, $stringData); fclose($fh); ?>
这只是一个样本。什么是正确的代码?
答案 0 :(得分:1)
你在那里使用正确的代码,有什么意义?
另请注意,您使用逗号而不是点来连接字符串:
$filename = $title , ".php";
答案 1 :(得分:1)
在您的示例中,使用POST打开文件是一种不安全的方法,所以甚至不要考虑这种技巧:P
您可以使用简单方法读取和写入文件
echo $fileData = file_get_contents('filename.txt');
$data= 'some data';
// Write the contents back to the file
file_put_contents("filename.txt", $data);