Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

unlink()

Example

Remove a file.

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

unlink(“test.txt”);
?>

Definition and Usage

The unlink() function removes a file.

Syntax

unlink(filenamecontext)

Parameter Values

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.

Technical Details

Return Value:

Returns TRUE on success, FALSE on failure.

PHP Version:

4.0+

PHP Changelog:

PHP 5.0 introduced the context parameter.