|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2015-03-17 08:43 UTC] ab@php.net
 
-Status: Open
+Status: Not a bug
  [2015-03-17 08:43 UTC] ab@php.net
  [2015-04-08 15:43 UTC] nathan dot renniewaldock at gmail dot com
 | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 18:00:01 2025 UTC | 
Description: ------------ symlink() fails to create a relative link if the working dir is not the same as where the link is going (works correctly on Linux). Relative targets should be resolved from the dir the link will be. For now, my workaround is calling mklink through shell_exec. Test script: --------------- <?php file_put_contents("test.txt", time()); mkdir("a"); echo "symlink(): "; symlink("..\\test.txt", "a\\1.txt") && print("success\n"); echo "\nmklink: ".shell_exec("mklink a\\2.txt ..\\test.txt"); echo "\nchdir(), symlink(): "; chdir("a"); symlink("..\\test.txt", "3.txt") && print("success\n"); Actual result: -------------- C:\php-test>php a.php symlink(): PHP Warning: symlink(): Could not fetch file information(error 2) in C:\php-test\a.php on line 7 Warning: symlink(): Could not fetch file information(error 2) in C:\php-test\a.php on line 7 mklink: symbolic link created for a\2.txt <<===>> ..\test.txt chdir(), symlink(): success C:\php-test>dir a Directory of C:\php-test\a 06/10/2014 15:21 <SYMLINK> 2.txt [..\test.txt] 06/10/2014 15:21 <SYMLINK> 3.txt [..\test.txt]