Remove a file.
| <?php $file = fopen(“test.txt”,“w”); echo fwrite($file,“Hello World. Testing!”); fclose($file); unlink(“test.txt”); ?> |
The unlink() function removes a file.
| unlink(filename, context) |
|
Parameter |
Description |
|
filename |
Required. Specifies the path to the file to be deleted. |
|
context |
Optional. Specifies the context for the file handle, which consists of options that can modify stream behavior. |
|
Return Value: |
Returns TRUE on success, FALSE on failure. |
|
PHP Version: |
4.0+ |
|
PHP Changelog: |
PHP 5.0 introduced the context parameter. |