1

I was wondering if it's possible to create a temporary page with a php script. Basically what I am wanting to do is have a file at example.com/example/button.php that will access a php script, and create text on say example.com/example/temppage.php. I simply only need it to say "shutdown" for 30 seconds on the temppage, and then it can go back to being blank.

Is this Possible? Thanks!

Konzine
  • 181
  • 1
  • 3
  • 7
  • *(reference)* http://php.net/spltempfileobject and http://php.net/tmpfile – Gordon Oct 04 '11 at 16:03
  • http://blog.stackoverflow.com/2011/02/are-some-questions-too-simple/ – Gordon Oct 04 '11 at 16:10
  • I am wondering if your idea for a temporary file is based upon a requirement or if you are just unfamiliar with php and its ability to generate dynamic content. Do you NEED to create a temporary file on the server? – horatio Oct 04 '11 at 17:19

2 Answers2

2

There actually is: click!

Or if you to lazy to click :D

$temp = tmpfile();
fwrite($temp, "writing to tempfile");
fseek($temp, 0);
echo fread($temp, 1024);
fclose($temp); // this removes the file
hoppa
  • 3,011
  • 18
  • 21
  • This is a step in the right direction, however I need a tempfile with a specific name that is deleted after 30 seconds.. Possible? – Konzine Oct 04 '11 at 17:13
1

Try tmpfile()

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