最近,我使用PHP在Visual中开发了一个聊天应用程序。
我使用了这个代码:
<?php
$msg = $_GET['w'];
$logfile= 'Chats.php';
$fp = fopen($logfile, "a");
fwrite($fp, $msg);
fclose($fp);
?> 我现在正试着制作一个在线记事本。我想要做的是在Visual中创建一个唯一的ID。这个唯一的ID必须是他的文件名。我不太擅长PHP,所以我想知道的是:
我希望唯一的ID是“笔记”的文件名。喜欢:$logfile= '{uniqueID.php}';
每当用户打开程序时,它都会打开他的uniqueID.php文件,他可以在我的程序中编辑这个文件。
长篇短篇小说(TL;DR)
我知道这不太安全,但这是为了让我自己学点东西。
发布于 2013-11-02 09:50:56
这应该会让你开始:
$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
}https://stackoverflow.com/questions/19740684
复制相似问题