PHP symlink() fails on Windows 7

こ雲淡風輕ζ 提交于 2019-11-27 19:28:19

问题


PHP symlink() function fails on Windows 7 with the error:

Warning: symlink(): Cannot create symlink, error code(3) in C:\xampp\htdocs\…\lib\model\doctrine\Website.class.php

It's a XAMPP server on with PHP 5.3.8.

From the symlink() documentation:

5.3.0 This function is now available on Windows platforms (Vista, Server 2008 or greater).

Any ideas/suggestions?


回答1:


Might be a bug in PHP 5.3 according to this:

https://bugs.php.net/bug.php?id=48975

and this:

http://forum.wampserver.com/read.php?2,64011 (reply #2)

Maybe you could upgrade to PHP 5.4 and see if it works?




回答2:


I use this

//symlink($target, $link);
exec('mklink /j "' . str_replace('/', '\\', $link) . '" "' . str_replace('/', '\\', $target) . '"');



回答3:


About PHP CLI on windows OS:
Do not forget to start the console with Run as Administrator else symlink will return false and raise the following error:

Warning: symlink(): Cannot create symlink, error code(1314)


来源:https://stackoverflow.com/questions/13376319/php-symlink-fails-on-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!