1--TEST-- 2Test symlink(), linkinfo(), link() and is_link() functions : usage variations - work on deleted link 3--SKIPIF-- 4<?php 5if (PHP_OS_FAMILY === 'Windows') { 6 require_once __DIR__ . '/windows_links/common.inc'; 7 skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__); 8} 9?> 10--FILE-- 11<?php 12/* Prototype: bool symlink ( string $target, string $link ); 13 Description: creates a symbolic link to the existing target with the specified name link 14 15 Prototype: bool is_link ( string $filename ); 16 Description: Tells whether the given file is a symbolic link. 17 18 Prototype: bool link ( string $target, string $link ); 19 Description: Create a hard link 20 21 Prototype: int linkinfo ( string $path ); 22 Description: Gets information about a link 23*/ 24 25/* Variation 5 : Creating link, deleting it and checking linkinfo(), is_link() on it */ 26 27$file_path = __DIR__; 28 29echo "*** Testing linkinfo() and is_link() on deleted link ***\n"; 30// link name used here 31$linkname = "$file_path/symlink_link_linkinfo_is_link_link_variation5.tmp"; 32 33// create temp dir 34$dirname = "$file_path/symlink_link_linkinfo_is_link_variation5"; 35mkdir($dirname); 36 37// filename used here 38$filename = "$dirname/symlink_link_linkinfo_is_link_variation5.tmp"; 39// create the file 40$fp = fopen($filename, "w"); 41$data = "Hello World"; 42fwrite($fp, $data); 43fclose($fp); 44 45var_dump( symlink($filename, $linkname) ); // create link 46 47// delete the link 48var_dump( unlink($linkname) ); // delete the link 49 50// clear the cache 51clearstatcache(); 52 53// try using linkinfo() & is_link() on deleted link; expected: false 54$deleted_link = $linkname; 55var_dump( linkinfo($deleted_link) ); 56var_dump( is_link($deleted_link) ); 57 58echo "Done\n"; 59?> 60--CLEAN-- 61<?php 62$file_path = __DIR__; 63$dirname = "$file_path/symlink_link_linkinfo_is_link_variation5"; 64$filename = "$dirname/symlink_link_linkinfo_is_link_variation5.tmp"; 65unlink($filename); 66rmdir($dirname); 67?> 68--EXPECTF-- 69*** Testing linkinfo() and is_link() on deleted link *** 70bool(true) 71bool(true) 72 73Warning: linkinfo(): No such file or directory in %s on line %d 74int(-1) 75bool(false) 76Done 77