tempnam -- 建立一个具有唯一文件名的文件
定义
string tempnam(string dir,string prefix)
参数
dir 创建路径 prefix 文件前缀(文件名开头)
例子
$cookie_file = tempname("/temp","cookie");
$handle = fopen($cookie_file,"w");
fwrite($handle,"writing to tempfile");
fclose($handle);
// do something
unlink($cookie_file);
PS: 使用 curl 调用 cookie 模拟登陆网站时,使用 tempnam 创建随机名称的 cookie 临时文件之后必须用 unlink,否则会导致一些不可预料的问题。
本文地址: https://blog.fbzl.org/tempnam建立一个具有唯一文件名的文件/ 代码库