The Tempnam () function creates a temporary file with a unique file name. If successful, the function returns a new temporary file name. If it fails, it returns false.
The Tempnam () function creates a temporary file with a unique file name.
If successful, the function returns a new temporary file name. If it fails, it returns false.
Grammar
Tempnam (Dir,prefix)
*/
function dir_wriable ($dir)//Custom Function extension Create temporary file
{
$test =tempnam ("$dir", "test_file"); Create a temporary file
if (fopen ($test, "w" > $fp = @fopen ($test, "w"))//If the file opened successfully
{
@fclose ($FP); Close File
@unlink ($test); deleting files
$wriable = "Ture"; return value is True
}
Else
{
$wriable =false or Die ("Cannot open $test!"); The return value is False
}
return $wriable; Returns a Boolean value
}
if (Dir_wriable (Str_replace ('//', '/', dirname (__file__))))//Call Custom function
{
$dir _wriable= ' success in document Creation ';
}
Else
{
$dir _wriable= ' failed to build the file ';
}
/*
If the PHP tutorial is unable to create the file in the specified dir parameter, it is returned to the system default value.
Note: The behavior of this function has changed in version 4.0.3. A temporary file is also created to avoid a competitive situation, which is the possibility that a file with the same name will exist in the file system between a string that is generated as a file name and a script that actually establishes the file. Note that if you no longer need the file, you will delete the file and not automatically delete it.
The Tmpfile () function establishes a temporary file with a unique file name in read-write (w+) mode.
The file is automatically deleted after it is closed (with fclose ()) or when the script is finished.
*/
$temp = Tmpfile ();
Fwrite ($temp, "testing, testing.");
Rewind the beginning of the file
Rewind ($temp);
Read 1k from a file
Echo fread ($temp, 1024);
deleting files
Fclose ($temp);
http://www.bkjia.com/PHPjc/632346.html www.bkjia.com true http://www.bkjia.com/PHPjc/632346.html techarticle the Tempnam () function creates a temporary file with a unique file name. If successful, the function returns a new temporary file name. If it fails, it returns false. The Tempnam () function creates a ...