Be warned that at least with php 5.3 on windows 2008 R2 the symlink function is effected by the statcache.
I got error 183 indicating the link existed. While the symlink was actually moved to a different location by another process and would certainly not exist anymore.
Calling clearstatcache with a filename does not work. Most probably as the filename is converted to a device path (e.g. "\Device\HarddiskVolume1\D-Drive\www\pp\#static\index.html") which is a requirement for the windows call.
easiest is to just call clearstatcache without a filename to resolve the issue.
if you really want to call clearstatcache with a filename you could use readlink on the already deleted symlink (that still lives in the statcache) to get the filename.
For example something like this:
<?php
if(@symlink('d:/www/pp/#static/index.html','d:/www/index.html')===false){
//link failed, perhaps a statcache issue? We try to get the target, if it is a statcache issue this should work just fine
if(($rl = @readlink($target))===false) return false; //not a cache issue as stat on a non-existing file failed, something else must be wrong...
//clear the stat cache for the actual target, strangely enough this works even-though this is the target and not the symlink to be created (*)
clearstatcache(true,$rl);
if(@symlink($source,$target) ===false) return false; //can't create the symlink
?>
*It looks for PHP on windows like the statcache is maintained on the target instead of the actual symlink (this would ease in getting the file properties and limit the size of the statcache)