从Url参数获取值并将其保存在txt文件中

时间:2013-07-17 09:38:02

标签: php

我想从url参数

中保存一个值

到服务器上的txt文件中。

$id = $_GET['id'];

我正在获得价值不知道如何在Txt文件中保存它。

4 个答案:

答案 0 :(得分:0)

您所要做的就是打开一个文件并写下内容:

 $fd = fopen("FILENAME","w");
 fwrite($fd, $id);
 fclose($fd);

查看PHP手册:PHP Filesystem funcions

答案 1 :(得分:0)

$filename = 'test.txt';
if ($handle = fopen($filename, "w")) {
    fwrite($handle, $id);
}
fclose($handle);

答案 2 :(得分:0)

你可以这样使用

$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $id;
fwrite($fh, $stringData);
fclose($fh);

答案 3 :(得分:0)

好的,你必须打开一个文件:

$datei_handle=fopen("part_of_url.txt",w);   

确保您使用正确的模式! 写下你的东西。

fwrite($datei_handle,$your_url_part);

关闭文件。

fclose($datei_handle);

还要查看曼努埃尔。我认为那里有很好的解释。 http://php.net/manual/de/function.fwrite.php

希望有所帮助。

相关问题