Menu Home

unlink

osbo.com | PHP | Functions | unlink

Deletes a file

Syntax

unlink ( string $filename [, resource $context ] ) : bool

Parameters

filename

Path to the file.

context

Note: For a description of contexts, refer to Streams.

Return

Returns TRUE on success or FALSE on failure.

Examples

filename

<?

$filename = 'unlink.txt';
$mode = 'a';

$handle = fopen($filename, $mode);

    $string = 'unlink';

    fwrite($handle, $string);

fclose($handle);

unlink($filename);

?>

			
			
		

context

<?

$filename = 'unlink.txt';
$mode = 'a';

$handle = fopen($filename, $mode);

    $string = 'unlink';

    fwrite($handle, $string);

fclose($handle);

$context = stream_context_create();

unlink($filename, $context);

?>

			
			
		

PHP