PHP unlink() Function

PHP fseek() Function
PHP umask() Function

In this article, you will learn how to delete or unlink a file in PHP. The unlink() function in PHP deletes a file.

what is the syntax of the UNLINK function in php?

unlink(filename, context)

Parameter Values

ParameterDescription
filenameRequired. Specifies the path to the file to delete
contextOptional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream
PHP unlink() method

examples of the UNLINK function

Example 1. In this example, we delete a file.

<?php
$file = fopen("test.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);

unlink("test.txt");
?>
PHP fseek() Function
PHP umask() Function

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top