1--TEST-- 2Testing unlink() function : basic functionality 3--FILE-- 4<?php 5/* Prototype : bool unlink ( string $filename [, resource $context] ); 6 Description : Deletes filename 7*/ 8 9$file_path = dirname(__FILE__); 10 11echo "*** Testing unlink() on a file ***\n"; 12$filename = "$file_path/unlink_basic.tmp"; // temp file name used here 13$fp = fopen($filename, "w"); // create file 14fwrite($fp, "Hello World"); 15fclose($fp); 16 17// delete file 18var_dump( unlink($filename) ); 19var_dump( file_exists($filename) ); // confirm file doesnt exist 20 21echo "\n*** Testing unlink() : checking second argument ***\n"; 22// creating a context 23$context = stream_context_create(); 24// temp file name used here 25$filename = "$file_path/unlink_basic.tmp"; 26$fp = fopen($filename, "w"); // create file 27fclose($fp); 28 29// delete file 30var_dump( unlink($filename, $context) ); // using $context in second argument 31var_dump( file_exists($filename) ); // confirm file doesnt exist 32 33echo "Done\n"; 34?> 35--EXPECTF-- 36*** Testing unlink() on a file *** 37bool(true) 38bool(false) 39 40*** Testing unlink() : checking second argument *** 41bool(true) 42bool(false) 43Done 44