📜  php 创建临时文件 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:10.490000             🧑  作者: Mango

代码示例1
// Works on Native Server
// $tmp = tmpfile();
// $newfilename = 'newfile.txt';
// fwrite($tmp, "This is a sample string as a content.");
// fseek($tmp, 0);

// Works on Google App Engine
$dir = sys_get_temp_dir();
$tmp = tempnam($dir, "foo");
file_put_contents($tmp, "hello");
//$f = fopen($tmp, "a");
//fwrite($f, " world");
//fclose($f);
//echo file_get_contents($tmp);