1--TEST-- 2Test unlink() function : usage variations - unlink links 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) == 'WIN') { 6 die('skip only on Linux'); 7} 8?> 9--FILE-- 10<?php 11/* Prototype : bool unlink ( string $filename [, resource $context] ); 12 Description : Deletes filename 13*/ 14 15/* Delete link files - soft and hard links */ 16 17$file_path = __DIR__; 18// temp file used 19$filename = "$file_path/unlink_variation3.tmp"; 20 21echo "*** Testing unlink() on soft and hard links ***\n"; 22// create temp file 23$fp = fopen($filename, "w"); 24fclose($fp); 25// link name used here 26$linkname = "$file_path/unlink_variation3_link.tmp"; 27 28echo "-- Testing unlink() on soft link --\n"; 29// create soft link 30var_dump( symlink($filename, $linkname) ); // expected: true 31// unlink soft link 32var_dump( unlink($linkname) ); // expected: true 33var_dump( file_exists($linkname) ); // confirm link is deleted 34 35echo "-- Testing unlink() on hard link --\n"; 36// create hard link 37var_dump( link($filename, $linkname) ); // expected: true 38// delete hard link 39var_dump( unlink($linkname) ); // expected: true 40var_dump( file_exists($linkname) ); // confirm link is deleted 41 42// delete temp file 43var_dump( unlink($filename) ); 44var_dump( file_exists($filename) ); // confirm file is deleted 45 46echo "Done\n"; 47?> 48--EXPECT-- 49*** Testing unlink() on soft and hard links *** 50-- Testing unlink() on soft link -- 51bool(true) 52bool(true) 53bool(false) 54-- Testing unlink() on hard link -- 55bool(true) 56bool(true) 57bool(false) 58bool(true) 59bool(false) 60Done 61