用Php创建临时文件


Creating A Temporary File in Php

我想知道是否有可能用php脚本创建一个临时页面。基本上我想做的是有一个文件在example.com/example/button.php,将访问一个php脚本,并在example.com/example/temppage.php上创建文本。我只需要它在页面上显示"关机"30秒,然后它就可以变回空白了。

这可能吗?谢谢!

确实有:点击!

或者如果你懒得点击:D

$temp = tmpfile();
fwrite($temp, "writing to tempfile");
fseek($temp, 0);
echo fread($temp, 1024);
fclose($temp); // this removes the file

尝试tmpfile()

<?php
$temp = tmpfile();
fwrite($temp, "writing to tempfile");
fseek($temp, 0);
echo fread($temp, 1024);
fclose($temp); // this removes the file
?>