Reputation: 46050
How do I remove a symlink with PHP on windows?
Running this:
mkdir('test');
symlink('test', 'test2');
unlink('test2');
Gives the following error:
PHP Warning: unlink(test2): Permission denied in C:\path\to\app\testlink.php on line 4
PHP Stack trace:
PHP 1. {main}() C:\path\to\app\testlink.php:0
PHP 2. unlink() C:\path\to\app\testlink.php:4
The directory and symlink were made correctly, just not removed.
Running:
Upvotes: 5
Views: 1552
Reputation: 46050
Ok, I figured it out. So Ill leave this here for future reference:
To remove a symlink to a directory use the rmdir
function:
mkdir('test');
symlink('test', 'test2');
rmdir('test2');
unlink
is for removing files.
Upvotes: 7