
Context options and parameters 
<?php
bool unlink ( str $filename , res $context = ? )
where,
$filename = Path to the file
$context = The resource context as created by
stream_context_create or set by
stream_context_set_option
?>
| STREAM CONTEXT WRAPPERS | ||
| ARRAY INDEX | NAME | |
| 0 | php | |
| 1 | file | |
| 2 | glob | |
| 3 | data | |
| 4 | http | |
| 5 | ftp | |
| 6 | zip | |
| 7 | compress.zlib | |
| 8 | https | |
| 9 | ftps | |
| 10 | phar | |
| ed48 | ||
EXERCISE
<?php
define("PAT1N", __DIR__ . '/temp/');
$srcpath01 = PAT1N;
echo $srcpath01 . '<br><br>';
$srcfile01 = 'sw7.jpg';
// THIS FILE MUST EXIST
$dstfile01 = 'sw7.copy.jpg';
if (file_exists($srcpath01 . $srcfile01))
{
if(copy($srcpath01 . $srcfile01, $srcpath01 . $dstfile01))
{
echo 'The ' . $srcfile01 . ' file WAS copied as ' . $dstfile01;
}
else
{
echo 'The ' . $srcfile01 . ' file WAS NOT copied as ' . $dstfile01;
}
}
else
{
echo 'The ' . $srcfile01 . ' file WAS NOT found.';
}
?>
EXERCISE
<?php
define("PAT2N", __DIR__ . '/temp');
$srcpath02 = PAT2N;
echo $srcpath02 . '<br><br>';
$srcfile02 = '/sw7.copy.jpg';
if (file_exists($srcpath02 . $srcfile02))
{
if(unlink($srcpath02 . $srcfile02))
{
echo 'The ' . $srcfile02 . ' file WAS DELETED as expected.';
}
else
{
echo 'The ' . $srcfile02 . ' file WAS NOT DELETED as expected.';
}
}
else
{
echo 'The ' . $srcfile02 . ' file WAS NOT found.';
}
?>
EXERCISE
<?php
define("PAT3N", __DIR__ . '/temp');
echo PAT3N . '<br><br>';
$trg03 = PAT3N . '/t1/';
$lnk03 = 'symlk03a';
// CREATES the symlk03a
// REMEMBER to use this function on Windows
// you must run the server as Administrator
symlink($trg03, $lnk03);
sleep(10);
// This symlink must be removed
// once its use has been completed
// in this case, after 10 seconds
// TRY TO REMOVE the symlk03a
unlink('symlk03a');
?>