我最近使用PHP在Visual Basic中创建了一个聊天应用程序。
我使用了这段代码:
<?php
$msg = $_GET['w'];
$logfile= 'Chats.php';
$fp = fopen($logfile, "a");
fwrite($fp, $msg);
fclose($fp);
?>
我现在正在尝试制作在线记事本。 我想要做的是在Visual Basic中创建一个唯一的ID。 这个唯一的ID必须是他的文件名。 我对PHP不太了解,所以我想知道的是:
我希望唯一ID是“Note”的文件名。
喜欢:
$logfile= '{uniqueID.php}';
每当用户打开程序时,它都会打开他的uniqueID.php文件,他可以在我的程序中编辑它。
Long Story Short(TL; DR)
我知道这不是很安全,但是要为自己学习一些东西。
答案 0 :(得分:0)
这应该让你开始:
$file = uniqid(true).'.php'; // generate unique filename
if(!file_exists($file)) { // if filename doesn't exist
file_put_contents($file, 'New user'); // write something to the file
}