Introduction
In this article I describe the PHP FileSystem functions tempnam, tempfile, touch, unmask and unlink. To learn some other FileSystem functions, go to:
- FileSystem Function in PHP: PART 1
- FileSystem Function in PHP: PART 2
- FileSystem Function in PHP: PART 3
- FileSystem Function in PHP: PART 4
- FileSystem Function in PHP: PART 5
- FileSystem Function in PHP: PART 6
- FileSystem Function in PHP: PART 7
- FileSystem Function in PHP: PART 8
- FileSystem Function in PHP: PART 9
- FileSystem Function in PHP: PART 10
- FileSystem Function in PHP: PART 11
- FileSystem Function in PHP: PART 12
- FileSystem Function in PHP: PART 13
- FileSystem Function in PHP: PART 14
- FileSystem Function in PHP: PART 15
- FileSystem Function in PHP: PART 16
- FileSystem Function in PHP: PART 17
The PHP FileSystem tempnam function is used to create file with unique file name and returns the new temporary file on success or false on failure.
Syntax
| tempnam(dir,prefix) |
Parameters in the tempnam function
The parameters of the function are:
| Parameter | Description |
| dir | It specifies the directory of where to create the temp file. |
| prefix | It specifies the start of the file name. |
Example
An example of the function is:
<?php
echo tempnam("C:\www\wamp","TempFile");
?>
Output
PHP tempfile() function
The PHP FileSystem tempfile function creates a temporary file and it returns a file handle or false on failure.
Syntax
| tmpfile() |
Example
An example of the function is:
<?php
$temp = tmpfile();
fwrite($temp, "Testing.............");
fseek($temp, 0);
echo fread($temp, 1024);
fclose($temp);
?>
Output
PHP touch() function
The PHP FileSystem touch function sets the access and modification time of a file and it returns true on success and false on failure.
Syntax
| touch(filename,time,atime) |



Join the conversation! Your thoughts help the community grow.