顯然,這是比我想象的更復雜一點。所以這是這個問題的第二遍。正如你所說你的應用程序將GET
或POST
信息到您的Web服務器應該存儲並返回一個密鑰的字符串。要做到這一點,我覺得最快的方法是使用一個平面文件,其中每一行都是字符串的索引。
<?php
define('FILEDB', 'str.db');
# Check if the file is there.
if (!file_exists(FILEDB))
die('No Such File.');
$file = file(FILEDB);
if (is_numeric($_POST['key']))
{ # We want to get a string.
# Check that file index is set.
if (!isset($file[$_POST['key']]))
die('File index not set.');
# Output string & End.
die($file[$_POST['key']]);
}
# Save new string to file database.
file_put_contents(FILEDB, implode(PHP_EOL, $file) . PHP_EOL . $_POST['key']);
# Output string & End.
die(count($file) + 1);
?>
這正是我在想阿爾弗雷德。我還需要知道我需要在服務器上安裝哪些內容才能使其工作。 Apache的? PHP? MySQL的? 如果你認爲你可以快速把一些東西扔在一起,一些基本的代碼會有所幫助。 – javajavajavajavajava